Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ipad detect when UIPopoverControllers are dismissed

I have several uiPopoverControllers in my universal iPad app. I now have a requirement to trigger a function once a certain popover has been dismissed. I can do this easily if the user clicks "close" inside the popover, but if they touch the screen to hide the popover, I cannot trigger my function.

I've been googling for some time and cannot seem to find any delegate methods which I might be able to use in my main view controller to capture them. I would love something like didDismissPopoverController - but my guess is it's not available.

IF not, I guess the only thing to do would be to detect the touches and trigger then? Basically I am highlighting a UITableView row and loading the popover. I need to deselect the row - so want to simply call [table reloaddata].

Thanks for any help on this one!

like image 616
Matt Facer Avatar asked Jan 02 '11 23:01

Matt Facer


1 Answers

You need to assign a delegate to the UIPopoverController and then implement the - (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController method. For example:

@interface FooController : UIViewController <UIPopoverControllerDelegate> {
    // ...
}
// ...
@end

When you instantiate the UIPopoverController (say, for this example, in FooController)...

UIPopoverController *popover = // ...
popover.delegate = self;

Then, you would implement the method:

- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController {
    // do something now that it's been dismissed
}

Granted, I haven't tested this but it seems like it should work...

Hope this helps!

like image 199
donkim Avatar answered Oct 06 '22 07:10

donkim