gpt4 book ai didi

objective-c - UIView HitTest :withEvent: calls come in threes

转载 作者:技术小花猫 更新时间:2023-10-29 10:16:42 26 4
gpt4 key购买 nike

我有一个没有 subview 的 UIScrollView。当我拖动 ScrollView 时,它的 hitTest:withEvent: 被调用了三次,而且事件中从来没有任何触摸。这是为什么呢(我看了另外一个帖子好像没有定论)?这是 ScrollView 的 hitTest...pointInside:withEvent:

的日志
2011-05-11 20:12:37.472 MyApp[10909:707] hit test for UIScrollView 119.500000,102.000000, timestamp: 357978 touches: {()}2011-05-11 20:12:37.475 MyApp[10909:707] pointInside for UIScrollView 119.500000,102.000000,  timestamp: 357978 touches: {()} 2011-05-11 20:12:37.477 MyApp[10909:707] hit test for UIScrollView 119.500000,102.000000, timestamp: 357978 touches: {()}2011-05-11 20:12:37.479 MyApp[10909:707] pointInside for UIScrollView 119.500000,102.000000,  timestamp: 357978 touches: {()} 2011-05-11 20:12:37.481 MyApp[10909:707] hit test for UIScrollView 119.500000,102.000000, timestamp: 358021 touches: {()}2011-05-11 20:12:37.482 MyApp[10909:707] pointInside for UIScrollView 119.500000,102.000000,  timestamp: 358021 touches: {()} 2011-05-11 20:12:37.484 MyApp[10909:707] pointInside for UIScrollView 119.500000,396.000000,  timestamp: 358021 touches: {()} 

最佳答案

hitTest: 是一种实用方法,旨在查找特定点的 View 。它代表用户点击触摸屏。多次调用 hitTest 以响应同一事件是完全明智的;所有方法应该做的是返回点下的 View ,它不应触发任何副作用。

如果你想跟踪触摸事件,你应该覆盖 touchesBegan: 和 friends。

关于objective-c - UIView HitTest :withEvent: calls come in threes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5972956/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com