我在透明的 UIView 下有一个 UIScrollView。我需要将所有平底锅和水龙头转移到滚动视图(仅水平滚动)。常规 UIView 使用 UIPanGestureRecognizer 的子类来跟踪垂直平移(子类在此处找到)。在覆盖视图中,我重写了触摸事件方法以将它们传递给 UIScrollView。
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
[self.scrollView.panGestureRecognizer touchesBegan:touches withEvent:event];
[self.scrollView.singleTapGesture touchesBegan:touches withEvent:event];
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesCancelled:touches withEvent:event];
[self.scrollView.panGestureRecognizer touchesCancelled:touches withEvent:event];
[self.scrollView.singleTapGesture touchesCancelled:touches withEvent:event];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesEnded:touches withEvent:event];
[self.scrollView.panGestureRecognizer touchesEnded:touches withEvent:event];
[self.scrollView.singleTapGesture touchesEnded:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesMoved:touches withEvent:event];
[self.scrollView.panGestureRecognizer touchesMoved:touches withEvent:event];
[self.scrollView.singleTapGesture touchesMoved:touches withEvent:event];
}
叠加视图,垂直平移完美运行。在 UIScrollView 中,水龙头也可以正常工作。滚动虽然不是那么多。滚动视图滚动大约三个点,然后停止(当我继续水平平移时)。如果我以一个速度放开,滚动视图然后拾取该速度并完成滚动。
导致滚动视图停止滚动然后加快速度的可能问题是什么?