我正在尝试从 UIMenuController 中删除默认菜单项。我找到了 UIWebview 或 UITextView 的这篇文章:
How to remove the default UIMenuItem from the UIMenuController in iOS?
我正在尝试为新的 iOS 5 方法执行此操作,您可以在表格选择上显示菜单项。所以我的类是 UIViewController 的子类,其中有一个 UITableView。我不确定如何或是否可以删除默认项目。谢谢!
最佳答案
TableView 委托(delegate)方法 -tableView:canPerformAction:forRowAtIndexPath:withSender:
正是用于此目的。
这是一个例子:
override func tableView(tableView: UITableView, canPerformAction action: Selector, forRowAtIndexPath indexPath: NSIndexPath, withSender sender: AnyObject?) -> Bool {
switch action {
case Selector("cut:"), Selector("copy:"), Selector("paste:"):
return false // as per your question
case Selector("myAction:"):
return true
default:
return false
}
}
关于iphone - 从 TableView 中的 UIMenuController 中删除默认的剪切、复制、粘贴功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10505755/