开发者

Why is the sender of an UIMenuItem action always nil?

开发者 https://www.devze.com 2023-01-27 01:06 出处:网络
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.

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.

This is my action method:

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

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

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;
}
开发者_StackOverflow

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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消