You could use one of the UIGestureRecognizerDelegate
methods like gestureRecognizerShouldBegin:
to specify which pan gesture is triggered in which situation.
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
// If the gesture is a pan, determine whether it starts out more
// horizontal than vertical than act accordingly
if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]]) {
UIPanGestureRecognizer *panGestureRecognizer = (UIPanGestureRecognizer *)gestureRecognizer;
CGPoint velocity = [panGestureRecognizer velocityInView:self.view];
if (gestureRecognizer == self.scrollView.panGestureRecognizer) {
// For the vertical scrollview, if it's more vertical than
// horizontal, return true; else false
return fabs(velocity.y) > fabs(velocity.x);
} else {
// For the horizontal pan view, if it's more horizontal than
// vertical, return true; else false
return fabs(velocity.y) < fabs(velocity.x);
}
}
else
return YES;
}