couldn\'t find a solution for that.
I am building an app, with big scroll view, who has paging (Horizontal). Inside this scroll view, there is a grid of UIView\'s, and a
You could subclass UIScrollView
and implement gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:
, allowing the scroll view's built-in panGestureRecognizer
to recognize simultaneously with another scroll view's gesture recognizers.
Example:
//This is needed because the public UIScrollView headers
//don't declare the UIGestureRecognizerDelegate protocol:
@interface UIScrollView (GestureRecognition)
@end
@interface MyScrollView : UIScrollView
@end
@implementation MyScrollView
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
if (gestureRecognizer == self.panGestureRecognizer) {
return YES;
} else if ([UIScrollView instancesRespondToSelector:@selector(gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:)]) {
//Note: UIScrollView currently doesn't implement this method, but this may change...
return [super gestureRecognizer:gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:otherGestureRecognizer];
}
return NO; //the default
}
@end
Using this subclass for either the horizontal, or all vertical scroll views should suffice.
You might actually find that you like the default behavior better, after you've tried using it this way. Allowing both views to scroll simultaneously will almost always lead to accidental vertical scrolling while swiping left and right, which can be irritating (most people don't do a perfectly horizontal swipe gesture).