Intercepting pan gestures over a UIScrollView breaks scrolling

后端 未结 3 1477
说谎
说谎 2020-12-13 12:48

I have a vertically-scrolling UIScrollView. I want to also handle horizontal pans on it, while allowing the default vertical scroll behavior. I\'ve put a transp

3条回答
  •  既然无缘
    2020-12-13 13:24

    OK, I figured it out. I needed to do 2 things to make this work:

    1) Attach my own pan recognizer to the scroll view itself, not to another view on top of it.

    2) This UIGestureRecognizerDelegate method prevents the goofy behavior that happens when both the default scrollview and my own one are invoked simultaneously.

    -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
        return YES;
    }
    

提交回复
热议问题