How to show “Copy” menu for a table cell?

后端 未结 1 1807
面向向阳花
面向向阳花 2021-01-12 05:57

I would add the option to copy the selected cell in a table like in the contacts app.

I have tried to follow this question about Objective-C and impliment t

相关标签:
1条回答
  • 2021-01-12 06:42

    You refer to an Objective-C example, but you have not done what it says to do! Your second method is the wrong method. You want to say this:

    override func tableView(tableView: UITableView, canPerformAction action: Selector, 
        forRowAtIndexPath indexPath: NSIndexPath, withSender sender: AnyObject?) 
        -> Bool {
            return action == #selector(copy(_:))
    }
    

    You will also need a third override:

    override func tableView(tableView: UITableView, performAction action: Selector, 
        forRowAtIndexPath indexPath: NSIndexPath, withSender sender: AnyObject?) {
            // ...
    }
    
    0 讨论(0)
提交回复
热议问题