Search code examples
iosuipopovercontroller

Detect the finish of `UIPopoverController` programmatic dismissal animation


UIPopoverControllerDelegate protocol have popoverControllerDidDismissPopover: method which invoked after popover has finished it's dismissal animation. However, if popover is dismissed programmatically, above-mentioned delegate method is not called.

Is there any way to detect the finish of programmatically triggered dismissal animation? In a nutshell, how to implement something like -[UIPopoverController dismissPopoverAnimated:completion:]?

P.S. Running completion block with 0.5 seconds timer is ugly


Solution

  • However, if popover is dismissed programmatically, above-mentioned delegate method is not called.

    A popover in iOS 8 is a presented view controller. Thus, if a popover is dismissed programmatically nowadays, it is done by calling dismissViewControllerAnimated:completion: which has a completion block where you'll be called back. You should not be using UIPopoverController at all.