有一个简单的方法使水平分页的UIScrollView包围? [英] Is there an easy way to make a horizontally paged UIScrollView wrap around?
问题描述
我注意到在股票应用程序中,小图绕回,例如:当您到达滚动视图的结尾并再次向右滑动时,您回到开始。在我开始编写代码之前,有没有一个简单的方法来做到这一点在SDK?我找不到任何属性或方法来实现这一点?
I notice that in the stocks application, the small graph wraps around, eg: when you get to the end of the scroll view and swipe right again, you go back to the beginning. Before I go ahead and code this myself is there an easy way to do this in the SDK? I can't find any properties or methods that would enable that?
我有一个分页的UIScrollView水平滚动,几乎完全像股票应用程序。 p>
I have a paged UIScrollView that scrolls horizontally, pretty much exactly like the stocks application one does.
推荐答案
我不认为有一个属性。我伪造它通过在每一端添加一个额外的页面,所以对于5页UIScrollView您可以设置contentSize为7页,并加载它们像这样:
I don't think there's a property to do this. I've faked it by adding an extra page on each end, so with for a 5 page UIScrollView you'd set the contentSize for 7 pages and load them like this:
5 1 2 3 4 5 1
5 1 2 3 4 5 1
然后在scrollViewDidEndDecelerating:中检查你是否在任一端,如果是这样,调用scrollRectToVisible:animated:在你的UIScrollView上跳转到真实页面1或5的位置(无动画)。
Then in scrollViewDidEndDecelerating:, check if you're at either end and if so call scrollRectToVisible:animated: on your UIScrollView to jump it to the "real" page 1 or 5 position (without animation).
这篇关于有一个简单的方法使水平分页的UIScrollView包围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!