Stop UIPopover from dismissing automatically

本小妞迷上赌 提交于 2019-11-29 12:23:11

问题


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?


回答1:


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




回答2:


- (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.




回答3:


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



来源:https://stackoverflow.com/questions/7129243/stop-uipopover-from-dismissing-automatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!