Possible Duplicate:
UIScrollView. Any thoughts on implementing “infinite” scroll/zoom?
I have a UIScroll which has eight or so pages. My aim is for them to 'loop' around so that when the user reaches the last page the first page will be the next page (and vice versa) so that the user could scroll through the pages endlessly. What is the best way to achieve this?
I am working from this example from Cocoa with Love.
Any help is greatly appreciated. Thank you.
For anyone else trying to solve this problem, I would recommend taking a look at apple's video, which includes a tutorial for infinite scrolling & wrapping: https://developer.apple.com/videos/wwdc/2011/
Along with its sample code: https://developer.apple.com/library/ios/#samplecode/StreetScroller/Introduction/Intro.html
I'm currently using the "8 1 2 3 4 5 6 7 8 1" method and haven't attempted to implement the method described in the video yet, but it appears that it could prevent the small "bounce" at the last or first page you can encounter when scrolling quickly on the 8 1 2...1 method.
Problem is sorted now. Basically, I created extra pages before and after my pages so it looks like this:
Then in the
scrollViewDidEndDecelerating
I do a simple if statement that checks if I am at either the first or last page and locate thescrollView
appropriately.