问题描述
我有一个使用 setContentOffset 自动滚动的 UITableView.像这样:
I have a UITableView that I'm autoscrolling with setContentOffset. Like so:
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];
我想要实现的是滚动平稳地减速和停止.我无法做到这一点.
What I want to achieve is for the scrolling to smoothly slow down and stop. I haven't been able to achieve that.
调用 [self.table.tblMinutes.layer removeAllAnimations] 停止动画,但由于某种原因移动了 contentOffset,没有达到我想要的效果.
Calling [self.table.tblMinutes.layer removeAllAnimations] stops the animation, but moves the contentOffset for some reason, not achieving what I want.
我尝试在动画中使用 UIViewAnimationOptionBeginFromCurrentState 选项,但没有任何效果.
I tried using the UIViewAnimationOptionBeginFromCurrentState option in a animation but that did nothing.
有什么建议吗?
推荐答案
这是中断现有动画并将其替换为不同动画的经典问题的子集.
This is a subset of the classic problem of interrupting an existing animation and replacing it with a different animation.
这里的问题是,如果你仅仅删除现有的动画,你会跳到那个动画的结尾.
The problem here is that if you merely remove the existing animation, you will jump to the end of that animation.
解决方案是在移除现有动画之前咨询表示层并将层设置到该位置.现在您从中游开始,可以应用另一个动画.
The solution to that is to consult the presentation layer and set the layer to that position before removing the existing animation. Now you are starting from midstream and can apply another animation.
这篇关于阻止 UITableView 自动滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)