I use UIMenuController when presenting my custom menu for the selected text on my WKWebview. But it is now deprecated on iOS 16, and get the following error
[Text] Using UIMenuController to add items into text menus is deprecated. Please implement the UITextInput API editMenuForTextRange:suggestedActions: instead.
[EditMenuInteraction] The edit menu ... did not have performable commands and/or actions; ignoring present.
And now I cant find any documentation on how to customize the menu on wkwebview.
This is what I am trying to present on the menu.
How can you customize the menu on the selected text on wkwebview?
I tried adding UITextInput, but it requires to conform to a bunch of protocols.
2
Answers
This isn’t possible just yet, but I think Apple is planning to add APIs for
UIEditMenuInteraction
soon. This is what I found in the WebKit source (mind theWK_IOS_TBA
availability specifier):UPDATE: These methods are showing up in the
WKUIDelegate
docs too now:I faced the same issue while presenting my custom menu in webview in iOS 16.
I implemented the following method and removed all non-required menu items as following and it was good to go:
Hope this helps, Cheers