如何在特定点停止UIScrollView? [英] How to stop a UIScrollView at a specific point?

查看:88
本文介绍了如何在特定点停止UIScrollView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在特定时间停止 UIScrollView ?也就是说,在用户交互后设置 UIScrollView 的最终位置?

How do you stop a UIScrollView at specific point? That is, set the final position of the UIScrollView after user interaction?

具体来说,如何在水平 UIScrollView 中设置间隔,以便它只在这些点停止?

Specifically, how can you set intervals along a horizontal UIScrollView, so that the it will only stop at these points?

我希望我所说的足够清楚。

I hope what I have said is clear enough.

推荐答案

看一下方法 scrollViewWillEndDragging:withVelocity:targetContentOffset: of UIScrollViewDelegate 。它打算完全按照您的需要进行操作。

Take a look at method scrollViewWillEndDragging:withVelocity:targetContentOffset: of UIScrollViewDelegate. It's intended to do exactly what you need.

当用户完成拖动滚动视图时,滚动视图会将此消息发送给其委托。第三个参数( targetContentOffset )作为指针传递,您可以更改其值以更改滚动视图将停止的位置。

The scroll view sends this message to its delegate when the user finishes dragging the scroll view. The third parameter (targetContentOffset) is passed as a pointer, and you can change its value to change where the scroll view will stop.

iOS 5.0及更高版本。

iOS 5.0 and later.

这篇关于如何在特定点停止UIScrollView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆