【问题标题】:Why is the sender of an UIMenuItem action always nil?为什么 UIMenuItem 动作的发送者总是 nil?
【发布时间】:2010-11-27 20:53:12
【问题描述】:

我已将UIMenuItem 实例添加到UIMenuController。当我在文本字段中点按两次时,我会在 Wikipedia 中获得包含复制、剪切、粘贴、查找的文本编辑菜单。

这是我的操作方法:

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

当我选择“在维基百科中查找”菜单项时,我得到了NSLog。但是 sender 总是 nil。

即使是-canPerformAction:withSender: 方法也不会收到除 nil 以外的任何内容。

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

我做错了什么还是这是一个已知的框架错误?

【问题讨论】:

  • 上次检查系统返回UIMenuController。但这和 nil 一样有用。但我找到了另一种向 UIMenuItem 添加块的方法。 github.com/steipete/PSMenuItem

标签: iphone ipad ios uimenucontroller


【解决方案1】:

我也遇到过一次。对我来说似乎是一个错误。

【讨论】:

    猜你喜欢
    • 2013-03-14
    • 1970-01-01
    • 2017-04-07
    • 1970-01-01
    • 2010-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多