Bobj-C
Bobj-C

Reputation: 5426

can I fire a notification when popover had disappeared (iPad)

I need to know by notification or whatever when the user press outside the popover frame.

Thanks

Upvotes: 3

Views: 1071

Answers (1)

Lorenzo B
Lorenzo B

Reputation: 33428

Why don't you implement UIPopoverControllerDelegate protocol?

Suppose you have a controller called MyController that displays the popover. In MyController.h says that it implements UIPopoverControllerDelegate like the following;

@interface DocumentViewController : UIViewController <UIPopoverControllerDelegate>

Now, in .m somewhere you could display the popover and set its delegate to self (it means that MyController will be the delegate for the popover).

UIPopoverController* pop = // init the popover here
pop.delegate = self;

At this point, you could implement the methods that are listed in that protocol (you must implement the required one, in general). In your case you could implement the following:

- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController
{
    // here I'm closing the popover...
}

- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{    
    // here I closed the popover...
}

For further info see UIPopoverControllerDelegate class reference.

Hope that helps.

Upvotes: 8

Related Questions