禁止关闭 uipopoverview 控制器

发布于 2024-11-27 16:28:35 字数 101 浏览 4 评论 0原文

当我们点击或触摸 popoverview 外部时,UIPopoverController 会自动关闭。 我想限制这种自动弹出窗口关闭。

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(4

遥远的绿洲 2024-12-04 16:28:36
self.myPopovercontroller.passthroughViews=[NSArray arrayWithObject:self.view];
self.myPopovercontroller.passthroughViews=[NSArray arrayWithObject:self.view];
药祭#氼 2024-12-04 16:28:36

重复的“是有没有办法在按下弹出窗口外部时不让弹出窗口消失?

有一个非常简单且合法的解决方案。在呈现 UIPopoverController 的视图控制器中,遵循 UIPopoverControllerDelegate 协议并实现以下委托方法。我刚刚测试了这个,它确实阻止了弹出窗口的关闭。

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

只需确保您已将弹出窗口控制器的委托设置为实现此功能的视图控制器。

您可以使用 [popoverController DismissPopoverAnimated:NO]; 方法关闭弹出窗口。

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.

神仙妹妹 2024-12-04 16:28:36

阅读 UIPopoverController文档。具体来说...

显示时,点击弹出窗口外部会导致弹出窗口
会被自动解雇。为了让用户能够与
指定视图而不关闭弹出窗口,您可以指定一个或
passthroughViews 属性的更多视图。点击弹出框内
窗口不会自动导致弹出窗口被关闭。你的
视图和视图控制器代码必须处理内部的操作和事件
显式弹出窗口并调用missPopoverAnimated:方法
需要。

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.

怂人 2024-12-04 16:28:36

在委托中实现 popoverControllerShouldDismissPopover: ,您可以阻止它消失,除非您希望它消失。

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

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