简体   繁体   English

分页UIScrollView-如何一次滑动多个页面

[英]Paging UIScrollView - How to flick multiple pages at a time

I have a paging scrollview much like Apple's Page Control example project which I have adapted into a horizontal picker. 我有一个分页滚动视图,非常类似于Apple的Page Control示例项目 ,该项目已适应水平选择器。 I would really like the ability to scroll through many pages per flick gesture instead of one-at-a-time, much like how UIPickerViews work. 我真的很希望能够以轻弹手势的方式滚动浏览许多页面,而不是一次滚动,就像UIPickerViews的工作方式一样。 Looking for some guidance on how to approach this. 寻找有关如何解决此问题的指导。 Thanks! 谢谢!

First here best Source Code 首先这里最好的 源代码

It could be that whatever is setting those numbers in there, is not greatly impressed by you setting the contentOffset under its hands. 可能在其中设置这些数字的任何内容都不会因您将contentOffset设置在其手下而给人留下深刻的印象。 So it just goes on setting what it thinks should be the contentOffset for the next instant - without verifying if the contentOffset has changed in the meantime. 因此,它只是继续设置它认为下一个瞬间的contentOffset,而不验证其间的contentOffset是否已更改。

I would subclass UIScrollView and put the magic in the setContentOffset method. 我将子类化UIScrollView并将其放在setContentOffset方法中。 In my experience all content-offset changing passes through that method, even the content-offset changing induced by the internal scrolling. 以我的经验,所有内容偏移更改都是通过该方法进行的,即使是由内部滚动引起的内容偏移更改也是如此。 Just do [super setContentOffset :..] at some point to pass the message on to the real UIScrollView . 只需在某些时候执行[super setContentOffset :..]即可将消息传递给真实的UIScrollView

Maybe if you put your shifting action in there it will work better. 也许如果您将换档操作放在那里,效果会更好。 You could at least detect the 3000-off setting of contentOffset , and fix it before passing the message on. 您至少可以检测到contentOffset的3000-off设置,并在传递消息之前对其进行修复。 If you would also override the contentOffset method, you could try and see if you can make a virtual infinite content size, and reduce that to real proportions "under the hood". 如果您还将覆盖contentOffset方法,则可以尝试查看是否可以创建虚拟的无限内容大小,然后将其“缩小”为实际比例。

This is also helpful for you..!!! 这对您也有帮助.. !!!

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

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