Delete by default, copy, paste from UIMenuController to TableView

I am trying to remove the default menu items from the UIMenuController. I found this post for UIWebview or UITextView:

How to remove default UIMenuItem from UIMenuController in iOS?

I am trying to do this for new iOS 5 methods where you can display a menu item in a table selection. So my class is a subclass of UIViewController in which there is a UITableView. I was not sure how or IF deleting elements by default was possible. Thank!

+5
source share
2 answers

The table delegate method is -tableView:canPerformAction:forRowAtIndexPath:withSender:designed for this purpose.

Here is an example:

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
    }
}
+1
source

cut, copy, paste select:

(BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
    UIMenuController * menuContoller=[UIMenuController sharedMenuController];    
    if (menuContoller) 
    {
        [UIMenuController sharedMenuController].menuVisible=NO;
    }
    return NO;
}
-5

All Articles