屏幕底部的 UIView Touch 事件未触发

发布于 2024-09-27 18:49:24 字数 230 浏览 2 评论 0原文

我遇到了一个奇怪的问题。我创建了一个发生在屏幕底部的 UIView (0,431,320,49) 然后我想处理触摸事件。

当我触摸 UIView 的上侧时,它就起作用了。但是当我触摸底部(我的意思是,相对位置超过 20px)时,touchBegan 事件不会被触发。

听起来我的网络状态栏有问题,它会以某种方式改变我的代码的行为。

有人有什么想法吗?

问候,

马蒂厄

I am encountering a strange problem. I created a UIView that takes place at the bottom of the screen
(0,431,320,49) and then I want to deal with touch events.

When I touch the upper side of the UIView, it works. But when I touch the bottom side (I mean, more than 20px in relative position), the touchBegan event is not fired.

It sounds like I have a problem with the network status bar that would change in some way the behavior of my code.

Does someone have any idea?

Regards,

Mathieu

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

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

发布评论

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

评论(1

梦冥 2024-10-04 18:49:24

也许您的 UIView 上方有一个透明视图,它接收触摸事件,并且不会将这些事件传递给其下方的视图。
或者,我遇到的另一个情况是,我为我的视图分配了错误的框架。上面的视图看起来不错,并且在未包含在错误帧中的某些点上无法接收触摸事件。

例如,我将帧(10,10,300,280)分配给我的viewController的视图,并向该视图添加一个帧为(0,0,320,480)的子视图。所以子视图看起来不错,但是无法接收到点(0, 0)处的触摸事件。

Maybe there is a transparent view above your UIView, it receives the touch event, and it does not pass those events to the view below it.
Or, another case I encountered, I assign the wrong frame to my view. The above views have a good looking, and touch event cannot be received at some point that is not contained in the wrong frame.

For example, I assigned frame (10,10,300,280) to my viewController's view, and add a subview with frame (0, 0, 320, 480) to the view. So the subview looks well, but touch event at point (0, 0) cannot be received.

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