有没有办法不让弹出框在外面按下时消失? [英] is there a way NOT to have the popover dismissed when pressing outside it?

查看:19
本文介绍了有没有办法不让弹出框在外面按下时消失?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 SDK 文档说

I know the SDK documentation says

点击弹出框内容之外的内容会自动关闭弹出框.

Taps outside of the popover’s contents automatically dismiss the popover.

但我相信这里的聪明人找到了办法:)也许我应该覆盖弹出框关闭功能?

But I'm sure the smart people here found a way :) maybe I should overwrite the popover dismiss function?

谢谢

我尝试按照此处的建议使用 passthroughViews,并且效果很好.这是任何需要它的人的代码 - 在本例中,我将 self.view 放入数组中,这意味着无论在哪里出现弹出框的按钮之外,都不会关闭弹出框.

I tried using the passthroughViews as was suggested here, and it works perfectly. Here's the code for whoever needs it - in this example, I put self.view in the array, which means that where ever outside the button where the popover was originated, nothing dismiss the popover.

        popoverController.passthroughViews = [[[NSArray alloc] initWithObjects:self.view, nil] autorelease];

推荐答案

您需要设置 passthroughViews 属性.来自文档:

You need to set the passthroughViews property. From the documentation:

当弹出框可见时用户可以与之交互的一组视图.

An array of views that the user can interact with while the popover is visible.

@property (nonatomic, copy) NSArray *passthroughViews

当弹出框处于活动状态时,与其他视图的交互通常会被禁用,直到弹出框被关闭.将视图数组分配给此属性允许弹出框外部的点击由相应的视图处理.

When a popover is active, interactions with other views are normally disabled until the popover is dismissed. Assigning an array of views to this property allows taps outside of the popover to be handled by the corresponding views.

passthroughViews 设置为要处理触摸事件而不是仅仅关闭弹出框的视图数组.

Set passthroughViews to an array of view(s) that you want to handle the touch event instead of just dismissing the popover.

这篇关于有没有办法不让弹出框在外面按下时消失?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆