子视图在所有窗口上获取触摸事件

发布于 2024-09-03 17:06:48 字数 374 浏览 4 评论 0原文

我的观点有点问题。

我有一个uiviewControler,加载一个xib。 在这个视图上我有一个 UIButton (触摸时工作正常)

我添加一个由代码创建的子视图(在不同的类上) 该视图响应她的触摸事件。

当我在我的视图上添加此子视图时,此视图上的事件正常,但我的第一个 uiview 上的 UIButton 不起作用。

我犯了一个错误?

编辑:

我做了一些测试。 我的 uiview 并不是真正单独加载的。事实上,我加载一个新的 uiviewController,并将其子视图添加到我当前的 uiviewController 中。

我的问题是由于我的新 uiviewController 的透明度拦截了我的触摸事件。

i have a little problem on my view.

I have a uiviewControler, load a xib.
on this view i have a UIButton ( on touch it's work fine)

I add a subview create by code (on a different class )
this view respond to her touch event.

when i add this subview on my view, the event on this view are ok, but the UIButton on my first uiview not work.

I have make an error ?

EDIT :

i have make some tests.
my uiview is not really load alone. in fact i load a new uiviewController, and add it's subview to my current uiviewController.

And my problem it's due to the transparence of my new uiviewController was intercep my touch event.

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

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

发布评论

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

评论(2

↘紸啶 2024-09-10 17:06:48

如果子视图的区域与按钮重叠,它将阻止其工作。如果子视图以模态方式显示,它将阻止按钮工作。否则,该按钮应该可以正常工作。

您的问题很可能出在其他地方。

If the subview's area overlaps the button it will prevent it from working. If the subview is displayed modally it will prevent the button from working. Otherwise, the button should work fine.

Your problem is most likely somewhere else.

‘画卷フ 2024-09-10 17:06:48

我已经更改了我的结构代码,我的视图仅由他的类(继承自 uiview )管理,并且我没有 uiViewController 来管理它。
在苹果文档中,他们说 uiview 控制器用于管理 Windows 上的多个 uiview,而在我的旧代码中不尊重这一点。

I have change my structure code, mow my view is only manage by his class ( herited from uiview ) and i have no uiViewController just for manage this.
On the apple documentation they say the uiview controller is for manage multiple uiview on windows, and in my old code not respect this.

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