I am using Xcode 10 Beta 6, so this might just be a bug.
I am trying to present a view controller (colorPickerController
) as a popover. Within that view controller I will be able to set some properties, which I want to read once the popover is dismissed.
Here's the code:
In lines 93...97 I define a completion handler.
In line 99 I present the colorPickerController
modally, including the completion handler.
When running the code the color picker controller was successfully shown in a popover. But when I tapped outside of the popover (to dismiss it), the callback was not called.
I thought maybe a UIPopoverPresentationController
does not dismiss "normally", so I tried manually dismissing the popover before it would do so itself, by calling dismiss
in popoverPresentationControllerShouldDismissPopover
(line 110).
Now this still didn't work, so I set a breakpoint as seen in the picture, to check if the delegate method is even being called.
That's when I noticed, that when running the app, the completion handler is called right when the popover appears, not when it dismisses.
I was logging Completion handler was called.
in the console, before even reaching the breakpoint.
How is this possible?