为什么UIMenuItem动作的发送者总是为零? [英] Why is the sender of an UIMenuItem action always nil?

查看:126
本文介绍了为什么UIMenuItem动作的发送者总是为零?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将 UIMenuItem 实例添加到 UIMenuController 。当我在文本字段中点击两次时,我在维基百科中获得了复制,剪切,粘贴,查找的文本编辑菜单。

I've added an UIMenuItem instance to UIMenuController. When I tap in a text field twice, then I get that text editing menu with Copy, Cut, Paste, Lookup in Wikipedia.

这是我的操作方法:

- (void)lookupInWikipedia:(id)sender {
    NSLog(%@"lookupInWikipedia: sender=%@", sender);
}

我得到 NSLog 当我选择在维基百科中查找菜单项时。但发件人总是为零。

I get the NSLog when I select the "Lookup in Wikipedia" menu item. But sender is always nil.

即使是 -canPerformAction:withSender:方法也会收到除发件人之外的任何内容。

Not even the -canPerformAction:withSender: method receives anything other than nil for sender.

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {
 NSLog(@"canPerformAction:withSender: = %@", sender);
 return YES;
}

我做错了什么或这是一个知道框架错误?

Am I doing something wrong or is this a know framework bug?

推荐答案

我也遇到过一次。对我来说看起来像个错误。

I also came across that once. Looks like a bug to me.

这篇关于为什么UIMenuItem动作的发送者总是为零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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