vomi
vomi

Reputation: 1163

NSPopover dismissal does not remove it from parent's presentedViewControllers (Xcode 11)

Using Xcode 11 & macOS 10.15, I have a ParentViewController that presents a PopoverViewController in .transient mode (= clicking outside the popover dismisses it).

When the user clicks outside the Popover, it is properly dismissed and the PopoverViewController is properly removed from ParentViewController.presentedViewControllers. --> OK

BUT, I have a button inside the popover that calls self.dismiss(self). The Popover is dissmised but not removed from ParentViewController.presentedViewControllers. --> PROBLEM

I do not think I've had this problem before.

Am I missing something here, or is this a bug in AppKit?

Thanks a lot for your help!

Upvotes: 0

Views: 197

Answers (1)

vomi
vomi

Reputation: 1163

Nevermind, I was doing it wrong.

As the documentation says, you have to call the dismiss from the presenting view controller.

Thus using self.presentingViewController?.dismiss(self) in the presented view controller solved the issue.

Upvotes: 2

Related Questions