How to avoid having two UIPopoverPresentationControllers up at same time each from UIBarButtonItem in UItoolBar

51 Views Asked by At

I'm in the process of converting an old iOS app which uses UIPopoverController to the new UIPopoverPresentationController. I have two popovers (A & B) each initiated from a click on a UIBarButtonItem (butA, butB) in a UIToolBar. I have the popovers each displaying fine. If I click in the main view the popovers disappear correctly.

If I press butA popover A appears. If I then press butB nothing happens. In this case, the popover controller B was being presented from the UIBarButtonItem (butB).

If I present the popovers from a sourceRect near butA and butB, I get a slightly different result. Click on butA and popover A appears. Click on butB popover A disappears. Click on butB a second time, then popover B appears.

How can I get this to work correctly, with popover A disappearing when I single click on butB? I have tried to dismiss ViewController A as part of the butB press action, but the ViewController A object at that point is nil.

Any help would be appreciated.

0

There are 0 best solutions below