I have two UIBarButtonItem
which both open up a popover with a navigation controller in my iOS 8 app. Both are setup using storyboards
and are of type Present As Popover
and "Animates" set to true. "Anchor" is set to corresponding UIBarButtonItem
.
In code this is the configuration before presenting the popover / performing segue.
override public func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
{
if segue.identifier == SEGUE_ID_ADD_ACTION {
if let actionViewController = (segue.destinationViewController as! UINavigationController).topViewController as? ActionViewController {
let newAction = Action()
actionViewController.selectedAction = newAction
actionViewController.delegate = self
}
}
else if segue.identifier == SEGUE_ID_FILTER {
let controller = (segue.destinationViewController as! UINavigationController).topViewController as! FilterViewController
controller.delegate = self
controller.setup(filter)
segue.destinationViewController.popoverPresentationController!.delegate = controller
}
}
Both shown view controller classes have no more popover specific code more than:
let size = CGSizeMake(320, 460)
self.navigationController?.preferredContentSize = size
in viewWillAppear
The problem I have is that when popover A is presented and I press the button to open popover B. An error is shown in log and nothing happens. Preferably popover B should be show or at lease hide popover B (similar to clicking anywhere else outside the popover). Error in log:
Warning: Attempt to present <UINavigationController: 0x7fbdac027000> on <xxx.ActionListViewController: 0x7fbdac075000> which is already presenting (null)
Adding
self.navigationController?.popoverPresentationController?.passthroughViews = nil
in the containing viewcontroller in the popover at least fixed so when clicking another button in the navigationitem did trigger a dismiss of the other popover.