3
votes

In my app, I'm designing a custom picker that allows the user to choose an item by scrolling horizontally and touching it. I need the buttons inside that view to loop around infinitely as the user scrolls in a certain direction. What would be the best way to tackle this feature while maintaining the inertial scrolling of UIScrollView when the content loops around out of the view?

From my research of others trying to attempt this, they have trouble maintaining the deceleration animation if the scroll position is programatically shifted mid-scroll after the user lifts their finger. How can I work around this limitation?

An example of an app that currently has this feature is Apple's MobileMe Gallery app. In the interface, after choosing a gallery, at the top, there is a horizontally scrollable photo picker that loops infinitely as it is dragged one direction.

Any advice is greatly appreciated.

2

2 Answers

3
votes

I wrote a general-purpose carousel control that can handle this sort of requirement easily and uses a simple datasource/delegate pattern for supplying the content views:

http://charcoaldesign.co.uk/source/cocoa#icarousel

I did use a UIScrollView as the basis originally, but that was fairly limiting so in the latest version I just manage the acceleration myself.

2
votes