如何在添加到子视图的视图中接收触摸

发布于 2024-10-09 02:05:21 字数 256 浏览 7 评论 0原文

我一直在向响应触摸的滚动视图添加几个子视图(“触摸子视图”)。每个子视图中的触摸委托方法都可以很好地触发。

我有一个子视图(bodyClock),它保存滚动视图的主要内容,它是 viewForZoomingInScrollView 。为了使“触摸”子视图正确缩放,我发现现在必须将它们添加到 bodyClock 子视图而不是滚动视图。然而,当我这样做时,“触摸子视图”不再响应触摸。

我已经与急救人员尝试了各种方法,但没有成功。任何为我指明正确方向的帮助将不胜感激。

I have been adding several subviews ("touch subviews") to a scroll view which respond to touches. The touch delegate methods in each of these subviews all fire nicely.

I have one subview (bodyClock) which holds the main content of the scroll view and is the viewForZoomingInScrollView. In order for the "touch" subviews to zoom properly I find now that I have to add them the bodyClock subview instead of the scroll view. When I do this, however, the "touch subviews" no longer respond to touches.

I have tried all sort of things with first responder without any success. Any help pointing me in the right direction would be appreciated.

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

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

发布评论

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

评论(1

凉墨 2024-10-16 02:05:21

好吧,我发现我的问题是我有一个子视图充当滚动视图中的时间掩码,我认为它正在响应触摸。当我注意到当遮罩覆盖在触摸子视图上时,触摸子视图没有响应触摸,这一点变得很明显。因为蒙版是滚动视图的子视图,所以在缩放时它会移动,这样 bodyClock 视图中的触摸子视图就会从蒙版下面出来并突然开始工作。

将蒙版从滚动视图移动到 bodyClock 子视图以及“触摸子视图”解决了我的问题。现在,所有子视图都可以正确滚动和缩放,并响应触摸。

OK, I found my problem I had a subview acting as a time mask in the scroll view that I think was responding to touches. This became evident when I noticed that the touch subViews did not respond to touches while the mask was over them. Because the mask was a subview to the scroll view, it would move when zooming such that a touch subview in the bodyClock view would come out from underneath the mask and suddenly start working.

Moving the mask from the scroll view to the bodyClock subView along with the "touch subviews" fixed my problem. Now all the subviews scroll and zoom properly, and respond to touches.

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