0

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

Yaroslav Dukal
  • 3,894
  • 29
  • 36

1 Answers1

0

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
}
RTXGamer
  • 3,215
  • 6
  • 20
  • 29
  • Unfortunately that did not help. Paste context menu is still present.... Fun fact that after your code sample "Cut" option has been added :D – Yaroslav Dukal Sep 15 '22 at 17:07
  • @YaroslavDukal its not happening at my end though, could you post a minimal reproducible example? – RTXGamer Sep 16 '22 at 05:22
  • the issue i found is connected to override func paste method. If comment it out all good. But i need that method to detect pasted images. Any ideas how i can fix that? – Yaroslav Dukal Sep 22 '22 at 06:00