user403015 user403015 - 1 year ago 119
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 ?


Answer Source

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];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download