从TableView中的UIMenuController中删除默认剪切,复制和粘贴
我正在尝试从UIMenuController中删除默认菜单项。我在UIWebview或UITextView上发现了这篇文章:
I'm trying to remove the default menu items from UIMenuController. I found this post for UIWebview or UITextView:
如何从iOS中的UIMenuController中删除默认的UIMenuItem?
我正在尝试为新的iOS 5方法执行此操作,您可以在表格选项上显示菜单项。所以我的类是UIViewController的子类,里面有一个UITableView。我不确定如何或如果删除默认项目是可能的。谢谢!
I'm trying to do this for the new iOS 5 methods where you can show a menu item on the table selection. So my class is a subclass of UIViewController that has a UITableView in it. I wasn't sure how or IF removing the default items was possible. Thanks!
表视图委托方法 -tableView:canPerformAction:forRowAtIndexPath:withSender:
正是出于此目的。
The table view delegate method -tableView:canPerformAction:forRowAtIndexPath:withSender:
is for this purpose exactly.
以下是一个例子:
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
}
}