Prevent Opening Additional Popover View from Navigation Bar Button Using UIPopoverController

In a recent iOS project for the iPad, I wanted to open a popover view from a bar button in the navigation bar. However, tapping somewhere on the navigation bar would not dismiss the popover view but (depending on where I tapped on the bar) open an additional popover view or even navigate to another view controller.

I do not know how this could happen but the PopoverController somehow added the navigation bar to its passthrough views. Therefore, manually resetting the passthrough views solved my problem:

1
2
[popoverController presentPopoverFromBarButtonItem:self.tourListButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[popoverController setPassthroughViews:nil];

Now, tapping anywhere on the screen (except the popover view) closes the view.

via stackoverflow

Posted in Cocoa, iOs, iPad