How to prevent UIPopoverPresentationController from being dismissed when clicking outside popover?

Kurt Anderson

In my universal iOS 8 app, I am presenting a popover using using UIPopoverPresentationController as seen 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'm presenting a view controller that looks like an alert, but isn't.

enter image description here

Now my issue is that the user can click outside of this popover and it gets dismissed. There's no real problem with that except that's not how alerts work and I would like this to emulate an alert.

I see that UIPopoverControllerDelegate had a method called popoverControllerShouldDismissPopover:, but UIPopoverPresentationControllerDelegate doesn't have that method, and I believe I need to use the latter.

matt

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to close Angular-bootstrap popover when clicking outside

From Dev

How to detect when a popover is dismissed in iOS 9

From Java

Prevent Bootstrap Modal from disappearing when clicking outside or pressing escape?

From Java

How to dismiss a Twitter Bootstrap popover by clicking outside?

From Dev

How to know when popover dismissed in iOS 9: popoverControllerDidDismissPopover deprecated

From Dev

How can I keep UIActionSheet from being dismissed when background touched?

From Dev

Hide Angular UI Bootstrap popover when clicking outside of it

From Dev

Run method when viewcontroller is accessed from another vc being dismissed

From Dev

Prevent "Dialog" Activity from interacting with background activity when clicking outside bounds

From Dev

angular js: Prevent Bootstrap Modal from disappearing when clicking outside or pressing escape?

From Dev

Prevent jquery autocomplete from closing the search result box when clicking outside

From Dev

How to stop my Alert Dialog from being immediately dismissed?

From Dev

Keep text in UITextView highlighted when the popover is dismissed

From Dev

Disabling a submit button when clicking on it , will prevent the form from being submitted on Google Chrome

From Dev

Disabling a submit button when clicking on it , will prevent the form from being submitted on Google Chrome

From Dev

How to prevent page from moving down when clicking on Log in button?

From Dev

How to prevent page from moving down when clicking on Log in button?

From Dev

Prevent kendo tooltip hide/close when clicking outside the tooltip?

From Dev

How to prevent database from being DDOSed by application when cache expires?

From Dev

How to prevent a thread from being terminated when conditions are not satisfied momentarily?

From Dev

How to prevent a <div> element from being resized when zooming

From Dev

How to prevent score from being overwritten when the same activity is called

From Dev

How to prevent a Fragment from being added when an Activity is closing

From Dev

How to prevent a thread from being terminated when conditions are not satisfied momentarily?

From Dev

How to prevent XSS vulnerability from being introduced when using .val()?

From Dev

How to prevent $() from being executed prematurely when creating an alias

From Dev

How to prevent data from being lost when page refreshed?

From Dev

AngularJS - How to hide a div when clicking outside of it

From Dev

How to resign focus on NSTextField when clicking outside

Related Related

  1. 1

    How to close Angular-bootstrap popover when clicking outside

  2. 2

    How to detect when a popover is dismissed in iOS 9

  3. 3

    Prevent Bootstrap Modal from disappearing when clicking outside or pressing escape?

  4. 4

    How to dismiss a Twitter Bootstrap popover by clicking outside?

  5. 5

    How to know when popover dismissed in iOS 9: popoverControllerDidDismissPopover deprecated

  6. 6

    How can I keep UIActionSheet from being dismissed when background touched?

  7. 7

    Hide Angular UI Bootstrap popover when clicking outside of it

  8. 8

    Run method when viewcontroller is accessed from another vc being dismissed

  9. 9

    Prevent "Dialog" Activity from interacting with background activity when clicking outside bounds

  10. 10

    angular js: Prevent Bootstrap Modal from disappearing when clicking outside or pressing escape?

  11. 11

    Prevent jquery autocomplete from closing the search result box when clicking outside

  12. 12

    How to stop my Alert Dialog from being immediately dismissed?

  13. 13

    Keep text in UITextView highlighted when the popover is dismissed

  14. 14

    Disabling a submit button when clicking on it , will prevent the form from being submitted on Google Chrome

  15. 15

    Disabling a submit button when clicking on it , will prevent the form from being submitted on Google Chrome

  16. 16

    How to prevent page from moving down when clicking on Log in button?

  17. 17

    How to prevent page from moving down when clicking on Log in button?

  18. 18

    Prevent kendo tooltip hide/close when clicking outside the tooltip?

  19. 19

    How to prevent database from being DDOSed by application when cache expires?

  20. 20

    How to prevent a thread from being terminated when conditions are not satisfied momentarily?

  21. 21

    How to prevent a <div> element from being resized when zooming

  22. 22

    How to prevent score from being overwritten when the same activity is called

  23. 23

    How to prevent a Fragment from being added when an Activity is closing

  24. 24

    How to prevent a thread from being terminated when conditions are not satisfied momentarily?

  25. 25

    How to prevent XSS vulnerability from being introduced when using .val()?

  26. 26

    How to prevent $() from being executed prematurely when creating an alias

  27. 27

    How to prevent data from being lost when page refreshed?

  28. 28

    AngularJS - How to hide a div when clicking outside of it

  29. 29

    How to resign focus on NSTextField when clicking outside

HotTag

Archive