Dismissing iPad UIPopoverController when BarButtonItem is pushed while it's open
Posted
by joshholat
on Stack Overflow
See other posts from Stack Overflow
or by joshholat
Published on 2010-04-15T02:38:53Z
Indexed on
2010/04/15
2:43 UTC
Read the original article
Hit count: 697
Using a split view on the iPad, I have the following code:
- (void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController:(UIPopoverController*)pc {
barButtonItem.title = @"Categories";
NSMutableArray *items = [[toolbar items] mutableCopy];
[items insertObject:barButtonItem atIndex:0];
[toolbar setItems:items animated:YES];
[items release];
self.popoverController = pc;
}
This works well to show the popover when the button is pressed. However, I'd also like to have the popover dismiss if the button is pressed while it is already open to follow good guidelines. How would I go about doing this? (i.e. if the user repeatedly clicks this button, the popover should come and hide every other hit.)
© Stack Overflow or respective owner