Inner UIScrollView and outer UIPanGestureRecognizer

Hi,

If there are nested UIScrollViews, they will work together nicely; when the inner scroll view reaches the end of contentSize, the outer scroll view will start scrolling.

Can we do the same with inner UIScrollView and outer UIView that has UIPanGestureRecognizer? I’ve tried using UIGestureRecognizerDelegate and return true in gestureRecognizer(_:shouldRecognizeSimultaneouslyWith:) but that will scroll the inner UIScrollView and fire the outer UIPanGestureRecognizer at the same time.

Thanks!

You could try using a dynamic failure requirement between the gestures. For example, you could use gestureRecognizer(_:shouldBeRequiredToFailBy:) to make the scroll view's pan gesture require the outer pan gesture to fail. And then you could use gestureRecognizerShouldBegin(_:) to make your outer pan gesture only begin if the scroll view is scrolled all the way to an edge.

Inner UIScrollView and outer UIPanGestureRecognizer
 
 
Q