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;               
    }
}

Leave a Comment