How to prohibit rejection of UIPopoverPresentationController when clicking outside popover?

In my iOS 8 generic app, I present a popover using the UIPopoverPresentationController , as shown below, from prepareForSegue :

 FavoriteNameViewController *nameVC = segue.destinationViewController; UIPopoverPresentationController *popPC = nameVC.popoverPresentationController; popPC.delegate = self; 

And with this delegate method.

 - (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller { return UIModalPresentationNone; } 

In this particular case, I present a view controller that looks like a warning, but it is not.

enter image description here

Now my problem is that the user can click outside of this popover and it will be rejected. There is no real problem, except that warnings do not work, and I would like this to emulate a warning.

I see that UIPopoverControllerDelegate had a method called popoverControllerShouldDismissPopover: but UIPopoverPresentationControllerDelegate does not have this method, and I believe I need to use the latter.

+5
source share
2 answers

You need to set the popover passthroughViews controller to nil and the modalInPopover view modalInPopover to YES.

+13
source

Try the following in your view

 -(BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event{ return YES; } 
-1
source

All Articles