in my splitviewcontroller iPad app I show a custom popover (which loads the rootviewController). How to show not only the table view, but also a navigationbar on top of it (to show the table title "Categories").
Here is my app:
My code to show the popover:
- (IBAction)showPopover:(UIButton *)sender {
if([self.popoverController isPopoverVisible])
{
[self.popoverController dismissPopoverAnimated:YES];
return;
}
// Build a custom popover view
TemplatesAppDelegate *delegate = (TemplatesAppDelegate*)[[UIApplication sharedApplication] delegate];
// Create a popover controller
self.popoverController = [[[UIPopoverController alloc] initWithContentViewController:delegate.rootViewController] autorelease];
// Present the popover view non-modal at the pressed button's position
[self.popoverController presentPopoverFromRect:sender.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
If you want a whole UINavigationController with all the functionalities, you can do like
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:delegate.rootViewController];
self.popoverController = [[[UIPopoverController alloc] initWithContentViewController:navController] autorelease];
[navController release];
Or if you want just a navigation bar you can add to your popovercontroller.
UINavigationBar *tableViewNavigationBar = [[UINavigationBar alloc] initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 44.0f)];
[self.popoverController addSubView:tableViewNavigationBar];
I didn't tested the code, but it should work.