开发者

disable dismissal of uipopoverview controller

开发者 https://www.devze.com 2023-03-25 14:08 出处:网络
UIPopoverContro开发者_开发技巧ller automatically dismisses when we tap or touch outside the popoverview.

UIPopoverContro开发者_开发技巧ller automatically dismisses when we tap or touch outside the popoverview. I want to restrict this automatic popover dismissal.


self.myPopovercontroller.passthroughViews=[NSArray arrayWithObject:self.view];


Duplicate of "is there a way NOT to have the popover dismissed when pressing outside it?"

There is a very simple and legit solution. In the view controller that presents your UIPopoverController, conform to the UIPopoverControllerDelegate protocol and implement the following delegate method. I just tested this and it does prevent popover to dismiss.

- (BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController
{
    return NO;
}

Just make sure that you have set the delegate of your popover controller to the view controller that implements this.

You can dismiss the popover by using [popoverController dismissPopoverAnimated:NO]; method.


Have a read of the UIPopoverController documentation. Specifically...

When displayed, taps outside of the popover window cause the popover to be dismissed automatically. To allow the user to interact with the specified views and not dismiss the popover, you can assign one or more views to the passthroughViews property. Taps inside the popover window do not automatically cause the popover to be dismissed. Your view and view controller code must handle actions and events inside the popover explicitly and call the dismissPopoverAnimated: method as needed.


Implement popoverControllerShouldDismissPopover: in the delegate, and you can stop it from disappearing unless you want it to.

0

精彩评论

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