Q:

how to detect a popover dismiss

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

A:

Assuming you are talking about the default behavior of popovers being dismissed when you tap outside of the popover, the solution to prevent this is to make the popover modal.
To do this, set the modalInPopover property to YES on the popover's content view controller.
BTW - if you want to detect when a popover is dismissed by the user by tapping outside of it, you need to implement the UIPopoverControllerDelegate method popoverControllerDidDismissPopover:.

A:

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.

