Xcode - HitTesting 返回 3 次
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您记录事件信息以及 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.