为什么UIScrollView的子类仍然滚动,即使我覆盖touchesMoved:withEvent:?

时间:2012-05-11 15:30:54

标签: iphone ios ipad uiscrollview uikit

在iOS 4中,我相信-touchesBegan:withEvent:,-touchesMoved:withEvent :, -touchesEnded:withEvent:, - ofTouchesCancelled:withEvent:是在视图中可用于处理触摸的唯一方法。

但是现在当我像这样覆盖这些方法时:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    // not calling super. Doing nothing.
}

在UIScrollView子类中,它仍然滚动。他们是怎么做到的?

1 个答案:

答案 0 :(得分:2)

UIScrollView使用UIPanGestureRecognizer进行滚动。 UIKit通过私有机制将事件发送到手势识别器,与touchesBegan:withEvent:和相关方法分开。

相关问题