从TableView中的UIMenuController中删除默认剪切,复制和粘贴 [英] Removing default cut, copy, paste from UIMenuController in a TableView

查看:114
本文介绍了从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
    }
}

这篇关于从TableView中的UIMenuController中删除默认剪切,复制和粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆