iphone - 从 TableView 中的 UIMenuController 中删除默认的剪切、复制、粘贴功能

标签 iphone uimenucontroller

我正在尝试从 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/

相关文章:

iphone - AVAudioPlayer 完全从 App 中移除

ios - 如何使 UITextView 能够接收粘贴的图像

ios - 在 WKWebView 中禁用整个 UIMenuController 编辑菜单

iphone - 如何使用C语言向数据库中插入数据?

ios - 如果用户在 iPhone 中关注它,则逐渐减少折线

ios - Flutter iOS 应用需要 Google 登录密码

iphone - iOS 中的自定义图像 mask

ios - 使用 swift 从 TextView 中选择文本后显示副本

swift - 如何快速删除 UIMenuController 项?