gpt4 book ai didi

ios - 停止 UITableView 自动滚动

转载 作者:行者123 更新时间:2023-11-28 21:36:24 26 4
gpt4 key购买 nike

我有一个使用 setContentOffset 自动滚动的 UITableView。像这样:

 CGFloat point = self.table.tblMinutes.contentSize.height - self.table.tblMinutes.bounds.size.height;

[self.table.tblMinutes setContentOffset:CGPointMake(0, point) animated:false];
[self.table.tblMinutes layoutIfNeeded];

[UIView animateWithDuration:20.0 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
[self.table.tblMinutes setContentOffset:CGPointMake(0, point - 500) animated:false];
} completion:nil];

我想要实现的是让滚动平稳地减速和停止。我没能做到这一点。

调用 [self.table.tblMinutes.layer removeAllAnimations] 停止动画,但由于某种原因移动 contentOffset,没有达到我想要的效果。

我尝试在动画中使用 UIViewAnimationOptionBeginFromCurrentState 选项,但没有任何作用。

有什么建议吗?

最佳答案

这是中断现有动画并将其替换为不同动画的经典问题的子集。

这里的问题是,如果您仅仅删除现有动画,您将跳到该动画的末尾。

解决方案是引用表示层 并在删除现有动画之前将层设置到该位置。 现在您从中途开始,可以应用另一个动画。

关于ios - 停止 UITableView 自动滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33766993/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com