开发者

uimenucontroller in uiwebview with custom menu items without MORE menu

开发者 https://www.devze.com 2023-01-28 02:07 出处:网络
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.

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 开发者_StackOverflow中文版| 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


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

`

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号