Xcode - HitTesting 返回 3 次

发布于 2024-09-28 09:31:38 字数 218 浏览 0 评论 0原文

我有一个 UIView 子类,其中 hitTest: withEvent: 被重写。每次注册命中测试时,视图都会记录其标签。

例如:点击

控制台: 你触摸过的视图:3 你触摸过的视图:3 您触摸了视图:3

我的问题:为什么它会执行三次?我需要它来触发 NSLog 以外的东西,而且我担心它也会触发三次。我可以轻松解决三重触发器,但我想知道是否有更好的解释。

I have a UIView subclass where hitTest: withEvent: is overridden. Every time a hit test registers, the view logs its tag.

Ex: Click

Console:
You Touched View: 3
You Touched View: 3
You Touched View: 3

My question: Why does it do it three times? I need it to trigger something other than an NSLog and I'm afraid that it will trigger that three times also. I could easily work around the triple trigger, but I was wondering if there was a better explanation.

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

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

发布评论

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

评论(1

维持三分热 2024-10-05 09:31:38

我建议您记录事件信息以及 uiview 的标签。它可能被多个事件调用 - touchDown、touchUp 等。

I suggest you log the event information as well as the uiview's tag. It could be getting called by multiple events - touchDown, touchUp, etc.

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