uimenucontroller in uiwebview with custom menu items without MORE menu

安稳与你 提交于 2019-12-05 02:27:57

问题


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:


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];
}

`



来源:https://stackoverflow.com/questions/4311009/uimenucontroller-in-uiwebview-with-custom-menu-items-without-more-menu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!