2

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?

Kampai
  • 22,848
  • 21
  • 95
  • 95
Proud Member
  • 40,078
  • 47
  • 146
  • 231
  • Last time I checked the system returned UIMenuController. But that's as useful as nil. But I found another way to add blocks to UIMenuItem. https://github.com/steipete/PSMenuItem – steipete Jul 17 '12 at 21:44

1 Answers1

1

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

BastiBen
  • 19,679
  • 11
  • 56
  • 86