更新时间:2023-11-18 13:13:58
In scrollViewWillBeginDragging
滚动视图尚未移动(或注册移动),因此 contentOffset
将为0.自IOS起5你可以改为查看scrollview的 panGestureRecognizer
来确定用户滚动手势的方向和大小。
In scrollViewWillBeginDragging
the scroll view has not yet moved (or registered the move) and so contentOffset
will by 0. As of IOS 5 you can instead look in the scrollview's panGestureRecognizer
to determine the direction and magnitude of the user's scrolling gesture.
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
CGPoint translation = [scrollView.panGestureRecognizer translationInView:scrollView.superview];
if(translation.x > 0)
{
// react to dragging right
} else
{
// react to dragging left
}
}