I have one UIScrollView
inside another UIScrollView
, both scrolling vertically. I’m having an issue where when I try to scroll the inner scroll view, the touches are also picked up just afterwards by the outer scroll view. I need touches in the inner scroll view to be exclusively handled by it, and for scrollViewDidScroll
to NOT be called on the parent scroll view.
I’ve tried all manner of things, subclassing the scroll view and overriding hitTest:withEvent
, setting canCancelContentTouches
, setting exclusiveTouch
, nothing work at all. The scrollViewDidScroll
methods are fired first on the inner one, then on the outer one.
How can I effectively kill the touch after the first scroll view, and not pass it up the responder chain to the outer scroll view?
(FYI: The hierarchy is that there’s a child view controller inbetween, so the outer scroll view contains a child view controller, which in turn contains the inner scroll view).
Apple definitely DOES NOT discourage UIScrollView inside UIScrollView. It's actually in the doc:
https://developer.apple.com/library/content/documentation/WindowsViews/Conceptual/UIScrollView_pg/NestedScrollViews/NestedScrollViews.html
If you want to disable the parent scroll view from scrolling, you can probably send a notification from the child, and set
isScrollEnabled
in parent.