Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIPopoverPresentationControllerDelegate methods only called on user dismissal

One of the biggest problems with popovers is how the delegate's dismiss methods (-[popoverPresentationControllerShouldDismissPopover:], -[popoverPresentationControllerDidDismissPopover:]) are only called if the user dismisses the popover, not if the popover is dismissed programmatically.

There's lots of important code in my dismiss methods that needs to get called. Is there an elegant solution to make sure this code gets called even on programmatic dismissal? (Sure, I can call "should" and "did" every time I dismiss...but that's error-prone and kind of gross.)

Thanks.

like image 344
Greg Maletic Avatar asked Oct 15 '14 18:10

Greg Maletic


1 Answers

I am not aware of a better solution than to manually call it each time you programmatically dismiss it.

[self popoverPresentationControllerDidDismissPopover:self.popoverPresentation];

This is quite common in the iOS SDK. For example, if you programmatically select a row in a table view, the delegate method tableView:didSelectRowAtIndexPath: will not be called.

like image 74
Jordan H Avatar answered Nov 01 '22 13:11

Jordan H