Intercepting pan gestures over a UIScrollView breaks scrolling

后端 未结 3 1485
说谎
说谎 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

    I had the same problem to solve and I did this:

    1) Attach my own pan recognizer to the scroll view.

    2) Return YES on: – gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:

    This will allow both gestures to work. So what that means is that on vertical scroll, both your panGesture delegate and scrollView Delegate will be fired. If it is a horizontal scroll, it will only call your panGesture delegate.

    3) in my panGesture delegate, detect if it is a horizontal scroll, if it is not, ignore.

提交回复
热议问题