how to detect a popover dismiss

ios, ipad, uipopovercontroller

Solution

Can use these two methods, but the second one suits your scenario:

 /* Called on the delegate when the popover controller will dismiss the popover.
    Return NO to prevent the dismissal of the view.
 */
- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController;

/* Called on the delegate when the user has taken action to dismiss the popover.
   This is not called when -dismissPopoverAnimated: is called directly.
 */
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController;

Remember to implement the UIPopoverdelegate and set the Delegate to self.

Problem

When a popover is open it closes if you click of it. Is is possible to stop this? Basically i have the following problem. When a popover closes i need a function to be processed. If i set a button with a dismiss function from the popover then i can put the function in the dismiss method however this isn't detected if the user clicks of the screen. So is is possible to stop a popover closing if you click off it. or Is it possible to detect this allowing the function i require to be called. Thanks James

Original source