I was wondering if there was a way to stop an iPad popover from dismissing automatically whenever you touch the screen outside the popover? If not, is there some kind of method similar to "popoverDidDismiss" that I could call to tell when the popover was dismissed?
3 Answers
Yes you can. This is right out of the Apple documentation.
When a popover is dismissed due to user taps outside the popover view, the popover automatically notifies its delegate of the action. If you provide a delegate, you can use this object to prevent the dismissal of the popover or perform additional actions in response to the dismissal. The popoverControllerShouldDismissPopover:
delegate method lets you control whether the popover should actually be dismissed. If your delegate does not implement the method, or if your implementation returns YES, the controller dismisses the popover and sends a popoverControllerDidDismissPopover:
message to the delegate.
Just return NO to the delegate method popoverControllerShouldDismissPopover:
Here is a link for further reading.

- 4,058
- 1
- 29
- 49

- 1,804
- 16
- 13
-
Thanks for the quick reply. I tried implementing this and it doesn't seem to be working. I should be putting it in the .m for the view where the popover appears, not the view inside the popover, right? – Luke Baumann Aug 20 '11 at 15:50
-
did you get this working? if so, how? if not, why is it marked as the correct answer? – ngb Apr 06 '13 at 14:55
-
Did you remember to make your view controller the delegate for the popover controller? – James White Apr 29 '13 at 15:13
-
404 on the link, just fyi – Dan Drews Apr 21 '14 at 18:48
- (BOOL) popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController
{
return NO;
}
That does it for you and you may assign a specific bar button item or something else in your popover to dismiss the popover.

- 10,094
- 5
- 24
- 51
-
I tried implementing this and it doesn't seem to be working. I should be putting it in the .m for the view where the popover appears, not the view inside the popover, right? – Luke Baumann Aug 21 '11 at 03:07
-
Yes. Did you indicate implementing the UIPopoverControllerDelegate in the header file? – Bourne Aug 23 '11 at 13:54
-
I think so. In the file that contains the contents of the popover, in the .h I have protocol OptionsViewControllerDelegate
-(void)didPick:(NSString *)string; end id delegate; and in the .m: synthesize delegate; and in the .h of the file where the popover appears I have: interface exampleViewController : UIViewController – Luke Baumann Aug 23 '11 at 20:05{ UIPopoverController *popoverController; OptionsViewController *optionsViewController; } Then synthesize the UIpopoverController and the OptionsViewController in the .m. Am I missing anything? Thanks. -
There are also (at)s in there, but I didn't have enough characters to put them in. Sorry. If it's too confusing I can send you a text file. Thanks SO much for all your help. – Luke Baumann Aug 23 '11 at 20:06
-
-
Still no luck. (Don't feel that I'm not grateful, though, I really appreciate all your help). – Luke Baumann Aug 24 '11 at 21:29