问题
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;
}
Am I doing something wrong or is this a know framework bug?
回答1:
I also came across that once. Looks like a bug to me.
来源:https://stackoverflow.com/questions/4293869/why-is-the-sender-of-an-uimenuitem-action-always-nil