Scrolling with two fingers with a UIScrollView

后端 未结 14 619
长发绾君心
长发绾君心 2020-11-29 21:29

I have an app where my main view accepts both touchesBegan and touchesMoved, and therefore takes in single finger touches, and drags. I want to im

14条回答
  •  一向
    一向 (楼主)
    2020-11-29 22:27

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

提交回复
热议问题