阻止 UIPopover 自动关闭
我想知道是否有办法阻止 iPad 弹出框在您触摸弹出框外的屏幕时自动关闭?如果没有,是否有某种类似于“popoverDidDismiss”的方法,我可以调用它来告诉弹出窗口何时被关闭?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,你可以。这是苹果文档中的内容。
当由于用户在弹出窗口视图之外点击而关闭弹出窗口时,弹出窗口会自动通知其委托该操作。如果您提供委托,则可以使用此对象来阻止弹出窗口的关闭或执行其他操作以响应关闭。
popoverControllerShouldDismissPopover:
委托方法可让您控制是否应实际关闭弹出窗口。如果您的委托未实现该方法,或者您的实现返回 YES,则控制器将关闭弹出窗口并向委托发送一条popoverControllerDidDismissPopover:
消息。只需向委托方法返回 NO
popoverControllerShouldDismissPopover:
这里有一个供进一步阅读的链接。
弹出窗口指南
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 apopoverControllerDidDismissPopover:
message to the delegate.Just return NO to the delegate method
popoverControllerShouldDismissPopover:
Here is a link for further reading.
Popover Guide
这就为您完成了,您可以在弹出窗口中分配特定的栏按钮项目或其他内容来关闭弹出窗口。
That does it for you and you may assign a specific bar button item or something else in your popover to dismiss the popover.
甚至可以使用
self.modallnpopover = yes;
如果您想在特定视图中关闭它,
self.modallnpopover = no;
如果您不想关闭它,则
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