阻止 UIPopover 自动关闭

发布于 2024-11-30 16:01:22 字数 99 浏览 2 评论 0原文

我想知道是否有办法阻止 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

伴我老 2024-12-07 16:01:22

是的,你可以。这是苹果文档中的内容。

当由于用户在弹出窗口视图之外点击而关闭弹出窗口时,弹出窗口会自动通知其委托该操作。如果您提供委托,则可以使用此对象来阻止弹出窗口的关闭或执行其他操作以响应关闭。 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 a popoverControllerDidDismissPopover: message to the delegate.

Just return NO to the delegate method popoverControllerShouldDismissPopover:

Here is a link for further reading.

Popover Guide

水晶透心 2024-12-07 16:01:22
- (BOOL) popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController
{
    return NO;
}

这就为您完成了,您可以在弹出窗口中分配特定的栏按钮项目或其他内容来关闭弹出窗口。

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

情栀口红 2024-12-07 16:01:22

甚至可以使用

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文