UIPopoverPresentationControllerDelegate methods are called only by user termination

One of the biggest problems with popovers is how delegate rejection methods ( -[popoverPresentationControllerShouldDismissPopover:] , -[popoverPresentationControllerDidDismissPopover:] ) are called only if the user rejects the popover, and not if the popover is rejected programmatically.

My removal methods have very important code that needs to be called. Is there an elegant solution to make sure this code is called even when the program is fired? (Of course, I can call "must" and "do" every time I quit ... but it's error-prone and rude.)

Thanks.

+6
source share
1 answer

I do not know a better solution than manually accessing it every time you reject it programmatically.

 [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.

+2
source

Source: https://habr.com/ru/post/976796/


All Articles