如何从iOS中的UIMenuController中删除默认的UIMenuItem?

use*_*015 2 iphone ipad ios

我想从UIMenuController中删除一些默认的UIMenuItem对象,如"剪切","复制"等.

怎么做 ?

谢谢.

Pet*_*art 6

对显示菜单的视图(例如UIWebView,UITextView)进行子类化,并覆盖-canPerformAction:withSender:以返回NO您不想显示的菜单项.

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
    if (action == @selector(copy:)) {
        return NO;
    }
    else {
        return [super canPerformAction:action withSender:sender];
    }
}
Run Code Online (Sandbox Code Playgroud)