I need to detect the user scroll direction to prevent wrong swipe. I use this following code
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
CGPoint velocity = [(UIPanGestureRecognizer *)gestureRecognizer velocityInView:self];
if (fabs(velocity.y) * 2 < fabs(velocity.x))
{
//scroll LEFT or RIGHT
return NO;
}
else
{
//scroll UP or DOWN
}
return YES;
}
it works in most case, except if the user scroll while the scrollview is decelerating, then the velocity factor is null, and i can't calculate the scroll direction.
EDIT 1
similar problem : link