pro*_*ock 14 cocoa-touch objective-c uiscrollview ios
我UIScrollView没有子视图.当我拖动滚动视图时,它hitTest:withEvent:会被调用三次,并且事件中永远不会有任何触摸.为什么会这样(我看到了另一篇文章,但它似乎没有包含在内)?这是滚动视图的日志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:是一种用于在特定点查找视图的实用方法.它DOES NOT表示用户点击触摸屏上.为响应同一事件,多次调用hitTest是完全合理的; 所有方法应该做的是返回点下的视图,它不应该触发任何副作用.
如果您想跟踪触摸事件,您应该覆盖touchesBegan:和朋友.
我不确定为什么,但以下是对这个问题的一些进一步的见解:
UIResponder才会调用方法。例如,touchesBegan:withEvent:直到最后才会被调用。我最好的猜测是,在某些情况下,调用之间的返回值hitTest可能会发生变化。但我想不出为什么会发生这种情况。如果这不是真的,那么多次调用它就没有意义。
另一个想法是代码编写效率低下。这看起来不太可能,但根据这些信息,这是有可能的。
| 归档时间: |
|
| 查看次数: |
4729 次 |
| 最近记录: |