如何创建具有“超大”尺寸的分页 UIScrollView页面
是否有建议的方法来创建页面比 UISrollView 边界更宽的分页 UIScrollView?
我需要这样的东西。
在 page2 和分页模式下正常滚动,页面边缘有“橡皮筋”效果。
分页效果对我来说看起来有点复杂,如果你快速滑动,你会进入下一页,如果你滑动缓慢,你会在边缘看到新页面,只有在某个点之后页面才会更改。
也许有人可以阐明处理此问题的方法,仅使用 UIScrollViewDelegate 方法是否可以实现这一点,或者我是否必须子类化?
Is there a suggested way to create a paging UIScrollView that has pages wider than the bounds of the UISrollView?
I would need something like this.
normal scrolling within page2 and paging mode with the "rubberband" effect on the edges of the pages.
The paging effect looks a bit complicated for me, if you flick fast you go to the next page, if you slide slow you see the new page at the edge and only after a certain point the page is changed.
Maybe somebody can shed some light on the way to handle this, is this even possible with the sole use of UIScrollViewDelegate methods or do I have to subclass?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我印象深刻。这实际上比我一开始想象的要容易得多。
简单的解决方案是将每个页面封装在非分页滚动视图中。完成了。无需实现 UIScrollViewDelegate,无需子类化。三行额外的代码
对于常规大小的页面,我有这样的东西:
现在我有这样的:
三行。惊人的。
视图层次结构:
I'm impressed. This was actually much much easier than I thought in the beginning.
The simple solution was to encapsulate each page in a non-paging scrollview. And done. No need to implement UIScrollViewDelegate, no need to subclass. Three extra lines of code
For the regular sized pages I had something like this:
and now I have this:
Three lines. Amazing.
The view hierarchy:
我使用了本教程 -
http://www.edumobile .org/iphone/iphone-programming-tutorials/pagecontrol-example-in-iphone/
如果您想制作更大的页面,您可以在本教程中增加 PageControlExampleViewControl 的视图大小。假设将其宽度设置为 360 而不是默认的 320。
I used this tutorial -
http://www.edumobile.org/iphone/iphone-programming-tutorials/pagecontrol-example-in-iphone/
if you want to make a larger page, you can increase the size of view of PageControlExampleViewControl in this tutorial. Lets say make its width to 360 instead of default 320.
据我所知,没有办法直接使用scrollviews分页属性来实现这一点。
您必须实现自己的 UIScrollView 子类,并且在实现文件中您需要实现:
使用
contentOffset
属性计算出滚动视图滚动了多少。并利用 UIScrollViews 的
scrollRectToVisible:
来实现您自己的自定义滚动功能。事件链类似于:记录开始触摸的位置,如果触摸移动,通过检查其 x/y 坐标是否大于或小于其起始位置来找出它移动的方向,如果touch 在屏幕上移动了足够的距离,然后使用
scrollRectToVisible:
按指定的分页大小滚动视图。As far as I know, there is no way of achieving this directly by using the scrollviews paging property.
You would have to implement your own
UIScrollView
subclass and within your implementation file you would need to implement:Work out how much the scroll view has scrolled using the
contentOffset
property.And make use of UIScrollViews's
scrollRectToVisible:
to implement your own custom scrolling functionality.The chain of events would be something like: record the location of a beginning touch, if the touch moves, find out which direction it moved by checking to see if its x/y coordinate is greater than or less than its starting position, if the touched moved a sufficient amount across the screen, then scroll the view by your designated paging size using
scrollRectToVisible:
.