Matt Rajca

blog projects github twitter email

Two-Finger Scrolling in UIScrollViews

May 22, 2016

Sometimes you want to require users to use two fingers instead of one when scrolling content with UIScrollViews. GarageBand, for example, does this with its on-screen piano keyboards, this way scrolling between octaves does not trigger key presses.

While you could implement this by overriding event handling code, there's an easier approach. As of iOS 5, UIScrollView exposes the gesture recognizer responsible for scrolling content via the panGestureRecognizer property. To require two-finger scrolling, you can simply change its minimumNumberOfTouches property to 2.