Please see the UITextInputTraits property, writingToolsBehavior. You can ... implement it on your custom UITextInput-conforming view
OK, I was able to try this and, unfortunately, it does not achieve the desired result: the Writing Tools menu item is still present in the custom view's Edit context menu (though it does nothing when selected).
I have a custom UIView subclass conforming to UITextInput, which uses UIEditMenuInteraction to provide an Edit context menu. The relevant code looks like this:
@implementation ConsoleView
{
UIEditMenuInteraction * _editMenuInteraction;
BOOL _editMenuIsVisible;
...
UIWritingToolsBehavior _writingToolsBehavior API_AVAILABLE(ios(18.0), macos(15.0));
}
...
@synthesize writingToolsBehavior = _writingToolsBehavior;
...
- (instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self) {
...
// disable iOS 18+ Writing Tools menu
if ( @available(iOS 18, macOS 15, *) ) {
_writingToolsBehavior = UIWritingToolsBehaviorNone;
}
...
I confirmed using the debugger that both the initialization code and the property accessor are executed, so that the property value is UIWritingToolsBehaviorNone. Yet the menu item remains.
Any other ideas?
I am able to use the -removeMenuForIdentifier: method, as mentioned above, to remove all other unwanted menu items from the edit context menu. It seems curious that the Writing Tools item should be handled differently.