The UIResponderStandardEditActions
protocol includes pasteAndMatchStyle:
. UITextView
conforms to UIResponderStandardEditActions
. But I can't find a way to get that menu to appear. I get the standard "Paste" menu. I've tried overriding pasteAndMatchStyle:
in a subclass of UITextView
. I've overridden canPerformAction:withSender:
but it never gets called with the pasteAndMatchStyle:
selector. I've implemented the textView:editMenuForTextInRange:suggestedActions:
delegate method. It's called but the suggested actions do not include the "Paste and Match Style" action (key command).
I came up with an ugly hack that involved overriding buildMenuWithBuilder:
and adding my own key command after the paste command. But this shouldn't be necessary considering it's supposed to be a standard edit action.
So what's the trick to make the "Paste and Match Style" edit menu appear properly in a UITextView
? I'm testing with iOS 17, 18, and 26.
By default context menus don't include a Paste and Match Style menu item, as it's not standard for that to be included in context menus (unlike the menu bar where it is standard to show that). If your app really wants to show this item, then overriding -buildMenuWithBuilder:
and adding your own command with the standard pasteAndMatchStyle:
action is the correct solution.