“定义”的选择器在iOS 5中编辑菜单项 [英] Selector for "Define" Edit Menu item in iOS 5

查看:136
本文介绍了“定义”的选择器在iOS 5中编辑菜单项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建自己的自定义编辑菜单(UIMenuController),并使用典型的

   - (BOOL)canPerformAction: (SEL)操作与发件人(id)发件人

方法有条件地启用/禁用系统默认值。典型的编辑方法有很好的记录(copy :, cut :,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,隐藏在明显的视野,但我花了几个小时寻找它,所以我会感谢任何帮助。具体来说,我需要:

  if(action == @selector(defineWord :))...... 

但是给我真正的代替defineWord:



ps - 我不介意知道方法属于什么类,只是出于好奇(复制:属于UIResponderStandardEditActions),例如

解决方案

定义选择器(_define :)实际上是私有的,如果您使用它,您的应用程序将被拒绝。我只需要在UITextView中显示Define菜单项即可,这是:

   - (BOOL)canPerformAction :(SEL)action withSender:(id)sender 
{
if(action == @selector(cut :) ||
action == @selector(copy :) ||
action == @selector(select :) ||
action == @selector(selectAll :) ||
action == @selector(paste :) ||
action == @selector(delete :))
{
return NO;
}
else return [super canPerformAction:action withSender:sender];
}


I'm building my own custom Edit Menu (UIMenuController) and am using the typical

-(BOOL)canPerformAction:(SEL)action withSender(id)sender

method to conditionally enable / disable system defaults. The typical edit methods are well documented (copy:, cut:, etc.), but I can't find anything about what method is called by the "Define" menu option to pull up the new word dictionary in iOS 5. Maybe it's hiding in plain sight, but I've spent hours looking for it, so I'd appreciate any help. Specifically, I need:

if (action == @selector(defineWord:)) ......

but give me what really goes in the place of "defineWord:"

ps - I wouldn't mind knowing what class the method belongs to, just out of curiosity (copy: belongs to UIResponderStandardEditActions, for example)

解决方案

The define selector (_define:) is actually private and your app will be rejected if you use it. What I had to do to get only the Define menu item to show up in a UITextView was this:

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
    if (action == @selector(cut:) ||
        action == @selector(copy:) ||
        action == @selector(select:) ||
        action == @selector(selectAll:) ||
        action == @selector(paste:) ||
        action == @selector(delete:))
    {
        return NO;
    }
    else return [super canPerformAction:action withSender:sender];
}

这篇关于“定义”的选择器在iOS 5中编辑菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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