Using a split view on the iPad, I have the following code:
- (void) splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController
This is a lot easier because the popoverController is a property. Makes it easier to reference.
if ([self.popoverController isPopoverVisible]) {
//using the setters and getters "goes thru the proper channels" when accessing objects
[self.popoverController dismissPopoverAnimated:YES];
} else {
UIPopoverController *pc = [[UIPopoverController alloc] initWithContentViewController:YOUR_VIEW_CONTROLLER];
self.popoverController = pc;
[pc release];
//get the button instance you set on the toolbar
UIBarButtonItem *categoryButton = [[toolbar items] objectAtIndex:0];
[self.popoverController presentPopoverFromBarButtonItem:categoryButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
I actually just realized that you're referring to the code inside the Delegate method for displaying the viewController at index:0 of your splitView. This answer doesn't necessarily apply to that, but does apply to any other time you're accessing and creating popoverControllers on the iPad. Without checking if a popover is visible first, you will either crash, or open several popovers.
Thanks for your time.