我会添加选项来复制联系人应用程序中的表格中的选定单元格.
我试图遵循this question关于Objective-C并在Swift中实现这些方法:
override func tableView(tableView: UITableView,shouldShowMenuForRowAtIndexPath indexPath: NSIndexPath) -> Bool { return true } override func canPerformAction(action: Selector,withSender sender: AnyObject?) -> Bool { return (action == #selector(NSObject.copy(_:))) }
但是,这是一个老问题,我无法使用Swift代码显示菜单.有人可以解释如何使用shouldShowMenuForRowAtIndexPath方法以及如何允许用户复制单元格.
解决方法
你指的是
an Objective-C example,但你没有做它说的事情!你的第二种方法是错误的方法.你想这样说:
override func tableView(tableView: UITableView,canPerformAction action: Selector,forRowAtIndexPath indexPath: NSIndexPath,withSender sender: AnyObject?) -> Bool { return action == #selector(copy(_:)) }
您还需要第三个覆盖:
override func tableView(tableView: UITableView,performAction action: Selector,withSender sender: AnyObject?) { // ... }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。