iOS 18 developer beta: UIMenuIdentifier for the new `Writing Tools` menu item?

I'm wondering how I can remove the new Writing Tools item from the context menu of a custom view, e.g. using removeMenuForIdentifier: in -buildMenuWithBuilder:.

Answered by tkmcintosh in 791262022

Here's what works for me:

    [builder removeMenuForIdentifier:UIMenuReplace]; // includes iOS 18 `Writing Tools`

Implementing the writingToolsBehavior property, either via @synthesize or hand-coded methods to always return UIWritingToolsBehaviorNone from getter and ignore setter calls, has no effect.

Please see the UITextInputTraits property, writingToolsBehavior. You can set this property on a UITextView, and you can implement it on your custom UITextInput-conforming view

Thanks, I’ll take a look.

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.

UIWritingToolsBehaviorNone is expected to fix this issue for you. Please file a feedback report as soon as it's convenient for you. There's still time for this issue to be fixed!

ps: A specific description of your case (even better, a sample app) will be invaluable

Accepted Answer

Here's what works for me:

    [builder removeMenuForIdentifier:UIMenuReplace]; // includes iOS 18 `Writing Tools`

Implementing the writingToolsBehavior property, either via @synthesize or hand-coded methods to always return UIWritingToolsBehaviorNone from getter and ignore setter calls, has no effect.

I have not been able to get the tools to display at all. I’m curious which Xcode beta, which simulator and which Sequoia beta you’re running. Do you see the tools in all text views, including SwiftUI ones? TIA for anything you can share about your setup.

iOS 18 developer beta: UIMenuIdentifier for the new `Writing Tools` menu item?
 
 
Q