更改 UIScrollView 滚动速度 [英] Change UIScrollView scroll speed

查看:109
本文介绍了更改 UIScrollView 滚动速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我有一个扩展 UIScrollView 并在用户滚动时填充其内容的视图.但是,如果用户滚动得太快,则不会按时创建在 UIScrollView 内填充的视图,您实际上可以看到 UIScrollView 的背景.发生这种情况的原因是因为我在 layoutSubviews 中执行这种延迟加载似乎不会在每次更改 contentOffset 属性时调用.

In my app I have a view that extends UIScrollView and populates its content as the user scrolls. However, if the user scrolls too fast the views being populated inside the UIScrollView don't get created on time and you can actually see the UIScrollView's background. The reason why this happens is because I'm doing this lazy loading in the layoutSubviews doesn't seem to get called every time the contentOffset property is changed.

如果您缓慢滚动 UIScrollView,则不会遇到我上面描述的问题,并且内容加载速度足够快.

If you scroll the UIScrollView slowly you don't run into the problem I described above and the content is loaded quickly enough.

我能想到的解决这个问题的唯一方法是,当用户从屏幕上抬起手指时,UIScrollView 的滚动速度不会超过一定的速度.

The only solution to this problem that I can think of is by making it so the UIScrollView doesn't scroll faster than a certain speed when the user lifts up his finger from the screen.

只是让您知道更改 decelerationRate 属性不是我的解决方案.DecelerationRate 告诉 UIScrollView 在用户抬起手指后它需要多快停止滚动.

Just so you know changing the decelerationRate property isn't my solution. DecelerationRate tells the UIScrollView how fast it needs to stop scrolling after the user lifts up the finger.

推荐答案

scroll.pagingEnabled = YES;

scroll.pagingEnabled = YES;

这篇关于更改 UIScrollView 滚动速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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