如何在特定点停止UIScrollView?

编程入门 行业动态 更新时间:2024-10-25 23:32:25
本文介绍了如何在特定点停止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?

本文发布于:2023-07-11 12:05:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1093994.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:在特定   UIScrollView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!