iPhone:UIScrollView 内无限循环内容

发布于 2024-09-05 00:35:34 字数 401 浏览 5 评论 0 原文

在我的应用程序中,我正在设计一个自定义选择器,允许用户通过水平滚动并触摸来选择项目。当用户向某个方向滚动时,我需要该视图内的按钮无限循环。当内容在视图外循环时,解决此功能同时保持 UIScrollView 惯性滚动的最佳方法是什么?

根据我对其他尝试这样做的人的研究,如果在用户抬起手指后以编程方式在滚动中间移动滚动位置,他们将难以维持减速动画。我该如何解决这个限制?

目前具有此功能的应用示例是 Apple 的 MobileMe Gallery 应用。在界面中,选择图库后,顶部有一个可水平滚动的照片选择器,向一个方向拖动时会无限循环。

非常感谢任何建议。

In my app, I'm designing a custom picker that allows the user to choose an item by scrolling horizontally and touching it. I need the buttons inside that view to loop around infinitely as the user scrolls in a certain direction. What would be the best way to tackle this feature while maintaining the inertial scrolling of UIScrollView when the content loops around out of the view?

From my research of others trying to attempt this, they have trouble maintaining the deceleration animation if the scroll position is programatically shifted mid-scroll after the user lifts their finger. How can I work around this limitation?

An example of an app that currently has this feature is Apple's MobileMe Gallery app. In the interface, after choosing a gallery, at the top, there is a horizontally scrollable photo picker that loops infinitely as it is dragged one direction.

Any advice is greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦行七里 2024-09-12 00:35:34

我编写了一个通用轮播控件,可以轻松处理此类需求,并使用简单的数据源/委托模式来提供内容视图:

http://charcoaldesign.co.uk/source/cocoa#icarousel

我最初确实使用 UIScrollView 作为基础,但这相当有限,所以在最新版本中我只管理我自己加速。

I wrote a general-purpose carousel control that can handle this sort of requirement easily and uses a simple datasource/delegate pattern for supplying the content views:

http://charcoaldesign.co.uk/source/cocoa#icarousel

I did use a UIScrollView as the basis originally, but that was fairly limiting so in the latest version I just manage the acceleration myself.

眼泪都笑了 2024-09-12 00:35:34

这里是一些示例代码,可以满足您的需求:-)

Here is some sample code that does what you want :-)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文