Search code examples
iphoneobjective-ciphone-sdk-3.0ios4uimenucontroller

NSNotifcation for UIMenuControllerWillShowMenuNotification


I am trying to listen for UIMenuController Notification in iphone sdk 3.0 .

But it seems that my notification can never get called. Here is my code:

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(menuControllerWillShow:) name:UIMenuControllerWillShowMenuNotification object:nil];

and my method

- (void)menuControllerWillShow:(NSNotification *)notification {
   NSLog (@"Call here");
}

But it never prints out "Call here", breakpoint never gets stop as well. Does anyone know how to solve this problem.

I know the approach of setMenuItems for iphone sdk 4.0 but I am working for sdk 3.0.

My original problem is that I am trying to catch the UIMenuController event to show a toolbar of buttons like: "Do A", "Do B" for the text. If anybody knows any solution for this, I also appreciate


Solution

  • Well, several people also had your problem:

    https://stackoverflow.com/questions/2959774/nsnotification-for-uimenucontrollerwillshowmenunotification

    http://www.iphonedevsdk.com/forum/iphone-sdk-development/36198-uimenucontrollerwillshowmenunotification-not-working.html

    http://www.iphonedevsdk.com/forum/iphone-sdk-development/50605-uimenucontroller-wont-send-notification.html

    The last one is interesting. This issue that you have appears to be a bug in pre-4.0. I couldn't find anything about whether there was a solution.