Stop UIPopover from dismissing automatically

后端 未结 3 1019
孤独总比滥情好
孤独总比滥情好 2020-12-31 09:04

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 met

相关标签:
3条回答
  • 2020-12-31 09:30

    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.

    Popover Guide

    0 讨论(0)
  • 2020-12-31 09:30

    even u can use

    self.modallnpopover = yes;

    if you want to dismiss it in a particular view

    self.modallnpopover = no;

    if you dont want to dismiss it

    0 讨论(0)
  • 2020-12-31 09:51
    - (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.

    0 讨论(0)
提交回复
热议问题