Use a UINavigationController that only contains your ViewController as the contents of the popoverController, for example:
MyViewController *myVC = [[myViewController alloc] init];
UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:myVC];
myPopoverController = [[UIPopoverController alloc] initWithContentViewController:navCon];
[myVC release];
[navCon release];
[myPopoverController presentPopoverFromRect:rect
inView:view
permittedArrowDirections:UIPopoverArrowDirectionRight
animated:YES];
Then, in your viewController control, set the navigationController elements:
self.navigationItem.title = @"myTitle";
self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemEdit target:self action:@selector(editButtonTapped:)] autorelease];
You can go crazy and put where you want:
self.navigationItem.titleView = [[MySpecialTitleView alloc] initWithFrame...];
The navigation controller will not move if there is only one ViewController in its stack.
iOS 7 caveat: NavigationBars inside popovers seems to ignore the hue in iOS 7. I think the error and recommend that you write an error report with apple if you encounter this problem.
source
share