uiwebview中的uimenucontroller,带有不带更多菜单的自定义菜单项 [英] uimenucontroller in uiwebview with custom menu items without MORE menu

查看:100
本文介绍了uiwebview中的uimenucontroller,带有不带更多菜单的自定义菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPad应用程序中,有一个UIWebview显示文本内容.当我点击保持并选择文本时,应该弹出一个带有2个自定义菜单的菜单.

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.

说,|菜单1 | MENU2 |

say, | MENU1 | MENU2 |

但是COPY菜单似乎也会随之出现,但我无法将其禁用.有禁用它的可能性吗?我在论坛上试过,没有解决的办法.

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.

所以我们可以保留COPY菜单以及其他2.现在应该是这样的

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

|复制|菜单1 | MENU2 |

| 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.

|复制|菜单1 | MENU2 |

| Copy | MENU1 | MENU2 |

OR

|菜单1 | MENU2 |

| MENU1 | MENU2 |

请给我一些解决方案....以多种方式进行尝试..但是没有任何结果... 请帮我...

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

谢谢, 布莱恩

推荐答案

在不替换UIMenuController的情况下似乎没有办法做到这一点.一种选择是处理自己的UILongPressGestureRecognizer(请参见如何删除COPY UIMenuItem在UIMenuController中).我已经看到一些建议,您可以覆盖canPerformAction,但这是行不通的.有趣的是,虽然似乎其他所有内容(cut:,select:等)都没有,但是从不调用"copy:"动作.

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

`

这篇关于uiwebview中的uimenucontroller,带有不带更多菜单的自定义菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆