简体   繁体   English

如何在iPhone中重复UIScrollView的内容?

[英]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). 我有7张图片,并且已经在UIScrollView中手动设置了它们(通过设置其高度和Y轴)。 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 ? 我怎样才能做到这一点 ?

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://iosdevelopertips.com/user-interface/creating-circular-and-infinite-uiscrollviews.html

http://www.iphonedevsdk.com/forum/iphone-sdk-development/54393-circular-scrollview.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 逻辑应该是这样的如果您已到达滚动视图的末尾(可以使用内容偏移量进行检查),则应将内容偏移量设置为第一张图片的内容偏移量,大多数为0。如果您在第一张图片上,则设置滚动视图的内容偏移量作为最后一个图像的内容偏移量

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM