Search code examples
iphoneobjective-ccocoa-touchios4

How can i repeat the contents of UIScrollView in iPhone?


I have 7 images and i have set them in UIScrollView manually (by setting its height and Y-axis). I want to repeat this images means after reaching at last image it should not stop it need to display first image. And same way for the top side.

How can i do that ?


Solution

  • I think you are looking for a circular scroll view. You can find lots of samples in net. Here are a few

    http://iosdevelopertips.com/user-interface/creating-circular-and-infinite-uiscrollviews.html

    http://www.iphonedevsdk.com/forum/iphone-sdk-development/54393-circular-scrollview.html

    The logic should be something like this If you have reached the end of the scrollview(which you can check using the content offset) you should set the content offset to that of the first image mostly 0. If you are at first image then set the content offset of the scrollview as the content offset of the last image