有什么方法可以在外面按下弹出器时被解雇? [英] is there a way NOT to have the popover dismissed when pressing outside it?

查看:86
本文介绍了有什么方法可以在外面按下弹出器时被解雇?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道SDK文档说


弹出窗口内容之外的点击会自动关闭popover。

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

但我确信聪明的人在这里找到了办法:)
也许我应该覆盖popover dismiss函数?

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(非原子,复制)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天全站免登陆