Remove Paste option from MenuItems in iOS 16

Viewed 60

I have a custom menu options written in

override func tableView(_ tableView: UITableView, canPerformAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) -> Bool { } 

in iOS 16 I see now a Paste option in the context option. I tried to hide it via

if action.description == "paste:" { return false } //FAILED


return action != #selector(UIResponderStandardEditActions.paste(_:)) // FAILED

but did not help. I see Paste option now everywhere. How to get rid of it ?

enter image description here

enter image description here

1 Answers

To remove the paste option from the default context menu, use this:

func tableView(_ tableView: UITableView, canPerformAction action: Selector, forRowAt indexPath: IndexPath, withSender sender: Any?) -> Bool {
    if action != #selector(UIResponderStandardEditActions.paste(_:)) {
        return true
    }
    return false
}
Related