Scrolling with two fingers with a UIScrollView

In SDK 3.2 the touch handling for UIScrollView is handled using Gesture Recognizers.

If you want to do two-finger panning instead of the default one-finger panning, you can use the following code:

for (UIGestureRecognizer *gestureRecognizer in scrollView.gestureRecognizers) {     
    if ([gestureRecognizer  isKindOfClass:[UIPanGestureRecognizer class]]) {
        UIPanGestureRecognizer *panGR = (UIPanGestureRecognizer *) gestureRecognizer;
        panGR.minimumNumberOfTouches = 2;               
    }
}

For iOS 5+, setting this property has the same effect as the answer by Mike Laurence:

self.scrollView.panGestureRecognizer.minimumNumberOfTouches = 2;

One finger dragging is ignored by panGestureRecognizer and so the one finger drag event gets passed to the content view.


In iOS 3.2+ you can now achieve two-finger scrolling quite easily. Just add a pan gesture recognizer to the scroll view and set its maximumNumberOfTouches to 1. It will claim all single-finger scrolls, but allow 2+ finger scrolls to pass up the chain to the scroll view's built-in pan gesture recognizer (and thus allow normal scrolling behavior).

UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(recognizePan:)];
panGestureRecognizer.maximumNumberOfTouches = 1;
[scrollView addGestureRecognizer:panGestureRecognizer];
[panGestureRecognizer release];