更改setContentOffset速度:动画:? [英] Change the speed of setContentOffset:animated:?

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

问题描述

有没有办法滚动的UITableView 使用setContentOffset时,改变动画的速度:动画:?我想它滚动到顶部,但速度缓慢。当我尝试以下,它会导致底部少数细胞动画开始(具体地,当滚动完成那将是不可见的那些)之前消失:

Is there a way to change the speed of the animation when scrolling a UITableView using setContentOffset:animated:? I want to scroll it to the top, but slowly. When I try the following, it causes the bottom few cells to disappear before the animation starts (specifically, the ones that won't be visible when the scroll is done):

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:3.0];
[self.tableView setContentOffset:CGPointMake(0, 0)];
[UIView commitAnimations];

解决此问题的任何其他办法吗?有 _setContentOffsetAnimationDuration 一个可行的私有方法,但我不希望被从App Store拒绝。

Any other way around this problem? There is a private method _setContentOffsetAnimationDuration that works, but I don't want to be rejected from the app store.

推荐答案

有没有这样做,也做你写的方式的直接方式。我能做到这一点的唯一方法是由我自己做的运动/动画。

There is no a direct way of doing this, nor doing the way you wrote it. The only way I can accomplish this is by making the movement/animation by my own.

例如移动1px的每1/10秒应模拟一个非常缓慢的滚动动画。 (自线性动画数学是很容易的!)

For example move 1px every 1/10 second should simulate a very slow scroll animation. (Since its a linear animation maths are very easy!)

如果你想获得更现实或幻想和模仿容易在易断的效果,那么你需要一些数学计算贝塞尔路径,这样就可以知道在每1/10秒的精确位置,例如

If you want to get more realistic or fancy and simulate easy-in easy-off effect then you need some maths to calculate a bezier path so you can know the exact position at every 1/10 second, for example

目前至少第一种方式不应该是困难的。
只需使用或 -performSelector:withObject:afterDelay或NSTimers

At least the first approach shouldn't be that difficult. Just use or -performSelector:withObject:afterDelay or NSTimerswith

-[UIScrollView setContentOffset:(CGPoint*)];`

希望它能帮助

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

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