user403015 user403015 - 5 months ago 59
iOS Question

How to remove the default UIMenuItem from the UIMenuController in iOS?

I want to remove some default UIMenuItem objects like "Cut", "Copy", etc, from the UIMenuController.

How to do that ?



Subclass the view that's presenting the menu (eg. UIWebView, UITextView) and override -canPerformAction:withSender: to return NO for the menu items you don't want to appear.

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