3
votes

In my iPad app, there is a UIWebview that displays text content. When I tap hold and select a text, a menu should popup with 2 custom menu.

say, | MENU1 | MENU2 |

But it seems the COPY menu will also accompany, which I couldn't disable. Is there any possibilities to disable it? I tried around the forum and no solutions worked out.

so itz okay to keep the COPY menu along with the other 2. which should now look like

| Copy | MENU1 | MENU2 |

But unfortunately, I 'm getting it displayed with a MORE menu as follows :

| Copy | More... |

Clicking the More... menu is showing the other 2 menu.

But I need all those 2 items to be displayed in the first attempt itself. either just the 2 menus alone, or atleast along with the copy menu.

| Copy | MENU1 | MENU2 |

OR

| MENU1 | MENU2 |

Get me some solution please.... Trying it out in many ways.. But nothing is working out... Plz help me out...

Thanks, Brian

1

1 Answers

2
votes

It doesn't appear that there is a way to do this without replacing the UIMenuController. One option is to handle your own UILongPressGestureRecognizer (see How to remove th COPY UIMenuItem in UIMenuController). I've seen proposals where you override canPerformAction, but this does not work. Interestingly, the "copy:" action is never called, though it seems that everything else (cut:,select:,etc.) is.

- (BOOL) canPerformAction:(SEL)action withSender:(id)sender
{
    if (action == @selector(defineSelection:))
    {
        return YES;
    }
    else if (action == @selector(translateSelection:))
    {
        return YES; 
    }
    else if (action == @selector(copy:))
    {
        return NO;
    }

    return [super canPerformAction:action withSender:sender];
}

`