Search code examples
ios7xcode5.1uimenucontroller

How to remove paste from UIMenuController?


I have added my own MenuItem to UIMenuController.But the problem is that it is also showing some default items like copy, paste etc. I want to remove these items and want to display my own menu item. I have also tried this code

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
    BOOL can = [super canPerformAction:action withSender:sender];

    if (action == @selector(showMyAlert:) )
    {
        can = YES;
    }
    if (action == @selector(paste:))
    {
        can = NO;
    }
    return can;
}

Here is the image.Paste item is showing along with my own item.So,please tell me how can i remove this Paste


Solution

  • you may subclass a UITextView or UITextField, and add these code below.

    - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
    {
        // Show your own menu item only
        return (action == @selector(showMyAlert:));
    }