如何从UIMenuController中删除粘贴?

时间:2014-05-30 05:02:27

标签: ios7 xcode5.1 uimenucontroller

  

我已经将自己的MenuItem添加到UIMenuController.But问题是它还显示了一些默认项目,如复制,粘贴等。我想删除这些项目,并希望显示我自己的菜单项。我也试过这段代码

- (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

1 个答案:

答案 0 :(得分:0)

您可以继承UITextViewUITextField,并在下面添加以下代码。

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