This is basically in continuation of: Dismissing iPad UIPopoverController when BarButtonItem is pushed while it's open, however I see the issue as large enough that it warranted another question.
Basically, they wanted to show the popover when the barbuttonitem (provided by the splitviewcontroller) is clicked, and then hide the popover when the same barbuttonitem is clicked again. They solved it by calling:
- (void)splitViewController:(UISplitViewController*)svc popoverController:(UIPopoverController*)pc willPresentViewController:(UIViewController *)aViewController{
if ([popoverController isPopoverVisible]) {
[popoverController dismissPopoverAnimated:YES];
}
}
However, I've come to the problem where on the first click of the barbuttonitem, this method is called correctly and it displays the popover. However, on any subsequent clicks of the barbuttonitem while the popover is open, this method is not called.
More puzzling, when I close the popover view through other means (clicking outside of the popover), then the popover closes automatically. However, a click on the button itself does not close the popover, nor does it call that "willPresentViewController" method.
Are there other means of catching this button click action? Or any thoughts on why the method is not called on a click of the button while the popover is open?