Nested UIScrollView: horizontal scrolling
Nested UIScrollView: horizontal scrolling
- Subject: Nested UIScrollView: horizontal scrolling
- From: Pierre de La Morinerie <email@hidden>
- Date: Fri, 23 Jul 2010 11:47:20 +0200
Hello,
I'm trying to scroll horizontally through a set of pages, where pages are grouped by two (and can be zoomed both together). So far, my view hierarchy is:
• One outter UIScrollView that scrolls horizontally.
• Several inner UIScrollView that contains two pages each, scrolling horizontally too.
The problem I have is that swiping quickly through pages makes the outter UIScrollView skip the inner pages : only the first page of the inner SV are visible, and then the outter UIScrollView skip directly to the next page group.
It seems that as long as the outter SV is moving (or decelerating, anyway), the inners SV won't have a chance to get the swipe events.
I tried several things so far :
• Use touchesShouldBegin:withEvent:inContentView:: If delaysContentTouch is disabled, this is called during multiple swipes — however touchesShouldCancelInContentView: is only called for the first swipe, and it's probably what would be usefull. So no luck there (I think).
• Disable scrolling on the outter SV (scrollEnabled = NO) when entering a page group, and re-enable it when the inner SV started to scroll (as then the inner SV will catch all the swiping events): my best try so far. However it's hard to detect which page group we're going to land on after several swipes. Plus it seems that an existing touch is not re-aquired right after scrollEnabled is re-activated, so I miss a few swipes, and the animation is not smooth as it should be (the scroll stops flatly on groups ends, then resumes on next swipe).
(Btw, the problem occurs whether paging is enabled or not: it really lies in the horizontal swipe handling, not in the paging behavior.)
In the end, my question is: how can I prevent the outter UIScrollView from getting all swipe events when it's decelerating, and tell it to pass them to the inners UIScrollViews instead?
Additional questions: How does the magic of nested UIScrollView actually works ? And would overriding 'hitTest:' on one of the ScrollViews be a good idea ?
I arranged a small sample Xcode project that demonstrates the issue and the possible fixes — it is available here : http://winosx.com/hosted_files/ZoomScrollTest.zip
Thanks!_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden