How to customize the pop up menu in iPhone?
Posted
by Allen Dang
on Stack Overflow
See other posts from Stack Overflow
or by Allen Dang
Published on 2010-03-17T02:04:09Z
Indexed on
2010/03/17
2:11 UTC
Read the original article
Hit count: 496
iphone-sdk
The application I'm creating needs a function like user selects some text, a pop up menu shows, and user clicks "search" menu to perform a search directly.
Problem is the current pop up menu provided by UIMenuController doesn't support to be extended. So my thought is to subscribe "UIMenuControllerDidShowMenuNotification", get the frame of pop up menu, and display the "search" button right aside.
But during the implementation, I met a strange problem, the notification seems never be sent, means after the menu shown, I still cannot be notified, following are the key section of code.
- (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(menuDidShow:) name:UIMenuControllerWillShowMenuNotification object:nil]; } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; [[NSNotificationCenter defaultCenter] removeObserver:self name:UIMenuControllerDidShowMenuNotification object:nil]; self.textView = nil; self.searchBar = nil; } - (void)menuDidShow:(NSNotification *)notification { NSLog(@"menu did show!"); }
The code is too simple to make mistake, can someone help me to understand what's going on? Or what did I miss?
© Stack Overflow or respective owner