Joe Joe - 1 month ago 15
Swift Question

TableViewCell copy property changed in Swift 3

I have a fairly simple question to ask.In my tableView, I am using canPerformAction to copy selected cell by applying long press to the selected cell.Everytime, When this action performed it shows the 'Copy' popup over the UITableViewCell in Xcode 7.But, After, I moved to Xcode 8 popup shows with more options like Cut,Copyand Paste like the screenshot below.Is there any possible solution to show only copy popup.I can upload a code on request. But, the code is fairly simple as you guys know.not much to show.Help is very much appreciated.

enter image description here

Thanks in Advance.

Answer

Though not sure why it is so, can you try to specify it explicitly by overriding canPerformAction delegate,

override func canPerformAction(_ action: Selector, withSender sender: AnyObject?) -> Bool {
    if action == #selector(cut(_:)) {
      return false
    }
    if action == #selector(paste(_:)) {
      return false
    }
    if action == #selector(select(_:)) {
      return false
    }
    if action == #selector(selectAll(_:)) {
      return false
    }
    ...

    return super.canPerformAction(action, withSender: sender)
  }