I wrote a subclass of UIScrollView that I use to scroll through the UITableView series. See the following diagram:

As you can see, I have several vertical scrollable UITableViews that scroll horizontally inside the parent UIScrollView. All of this works great. However, the application has a number of global gestures. For example, if I scroll in this direction with two fingers, I make the UIView move to another part of the application. but if I make a gesture on top of the scroll view and / or its child table views, they will naturally scroll their contents. This does not look good and causes some layout problems.
I would like to figure out how to disable all scrolling on both UIScrollView and its child UITableViews when the user touches anywhere with two fingers and only two fingers. I tried overriding options for touchBegan, touchsEnded, touchsShouldCancel, etc .... but I can't figure it out completely correctly. Any help is greatly appreciated.
Here is my gesture processing code:
UISwipeGestureRecognizer *twoFingerSwipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleTwoFingerSwipe:)]; [twoFingerSwipeUp setNumberOfTouchesRequired:2]; [twoFingerSwipeUp setDirection:UISwipeGestureRecognizerDirectionUp]; [twoFingerSwipeUp setDelegate:self]; // 'self' is the superview of the UIScrollView, which is a UIView. [self addGestureRecognizer:twoFingerSwipeUp]; [twoFingerSwipeUp release]; // ... repeat the above code for up, down, left, right gestures ... - (void)handleTwoFingerSwipe:(UISwipeGestureRecognizer*)swipeGesture { switch ([swipeGesture direction]) { case UISwipeGestureRecognizerDirectionUp: [self changeToView:viewAbove]; break; case UISwipeGestureRecognizerDirectionDown: [self changeToView:viewBelow]; break; case UISwipeGestureRecognizerDirectionRight: [self changeToView:viewToTheRight]; break; case UISwipeGestureRecognizerDirectionLeft: [self changeToView:viewToTheLeft]; break; } }
source share