开发者

Stop UIPopover from dismissing automatically

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?


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


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


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜