disable dismissal of uipopoverview controller

笑着哭i 提交于 2019-12-23 05:52:07

问题


UIPopoverController automatically dismisses when we tap or touch outside the popoverview. I want to restrict this automatic popover dismissal.


回答1:


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



回答2:


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.




回答3:


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.




回答4:


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



来源:https://stackoverflow.com/questions/6898347/disable-dismissal-of-uipopoverview-controller

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