iOS 5中"定义"编辑菜单项的选择器

Mic*_*ael 5 dictionary definition selector ios

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

-(BOOL)canPerformAction:(SEL)action withSender(id)sender
Run Code Online (Sandbox Code Playgroud)

有条件地启用/禁用系统默认值的方法.典型的编辑方法有很好的文档记录(copy:,cut:等),但我找不到任何关于在"定义"菜单选项中调用什么方法来提取iOS 5中的新单词字典.也许它是躲在明显的视线中,但我花了几个小时寻找它,所以我很感激任何帮助.具体来说,我需要:

if (action == @selector(defineWord:)) ......
Run Code Online (Sandbox Code Playgroud)

但请告诉我"defineWord"的真正含义:

ps - 我不介意知道这个方法属于哪个类,只是出于好奇(例如,copy:属于UIResponderStandardEditActions)

Jer*_*emy 5

通过实现这个:

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
    NSLog(@"%@", NSStringFromSelector(action));
}
Run Code Online (Sandbox Code Playgroud)

我能够看到选择器是"_define:".


Ric*_*ier 5

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

- (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];
}
Run Code Online (Sandbox Code Playgroud)