I haven't tried that yet, but I assume that I would have to disable scrolling of the parent scroll view as soon as I know that the user will want to scroll in the child scroll view, right?
Both scroll views are scrolling horizontal.
How could I disable scrolling detection of the parent temporarily? Or is there some other way?
It is very possible. The easiest way is to disable the
scrollEnabled
property, you can also try set the outerUIScrollView
'scontentSize
to its bounds, so that it won't scroll. Depending on what you need, you may set No tobounce
as well but that'll basically make your scroll view like a regular UIView.If you have control over all the child
UIScrollView
's, you can implementUIScrollViewDelegate
protocol, but if you don't, or your childUIScrollView
is really aUITableView
, orUICollectionView
, then you can't really rely theUIScrollViewDelegate
protocol, but rememberUIScrollView
comes with apanGestureRecognizer
and you can play with that. A powerful but heavy handed way is to add an observer on thepanGestureRecognizer
'sstate
property so that you can capture all the events without being the delegate of theUIScrollView
in question.UIScrollView has a property called
scrollEnabled
, which you can set toNO
to disable scrolling in your parent scroll view.I haven't tried it yet, but you may just find that it Does The Right Thing, i.e., the inner scroll view scrolls until it can't scroll any more, at which point the outer scroll view scrolls.
I did this and it does cause the parent scrollView NOT to scroll anymore which is fine but my child scrollView which was pushed via presentModalViewController still does not respond to scroll events (e.g. scrolling up or down). I'm obviously missing something...
EDIT: Got it to work finally by using 'scrollEnabled' on the parent view. Thanks.
I had this same problem till I set dynamically enough height to the contentSize of the inner ScrollView, using:
Obviously this is just a hardcoded example, you should set the height needed to display the whole content of the view, and maybe no scroll is needed in the end.
It seems that setting the height of the scrollView using the IBuilder is not enough, so no scroll was needed and that's why I was thinking that the sweep event wasn't reaching the inner scroll.
Hope this helps!