gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 22:57:11 25 4
gpt4 key购买 nike

在 iOS 4 中,我相信 -touchesBegan:withEvent:、-touchesMoved:withEvent:、-touchesEnded:withEvent:、-touchesCancelled:withEvent: 是唯一可在 View 中实现以处理触摸的方法。

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

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

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

最佳答案

UIScrollView 使用 UIPanGestureRecognizer 来滚动。 UIKit 通过私有(private)机制向手势识别器发送事件,与 touchesBegan:withEvent: 和相关方法分开。

关于iphone - 为什么即使我覆盖 touchesMoved :withEvent:? UIScrollView 的子类仍然滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10554374/

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