阻止 UITableView 自动滚动

Stop a UITableView from automatically scrolling(阻止 UITableView 自动滚动)
本文介绍了阻止 UITableView 自动滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 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 自动滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
Dropbox Files.download does not start when number of files in folder is gt; 1000(当文件夹中的文件数为1000时,Dropbox Files.Download不会启动)
How to target newer versions in .gitlab-ci.yml using auto devops (java 11 instead of 8 and Android 31 instead of 29)(如何在.gitlab-ci.yml中使用自动开发工具(Java 11而不是8,Android 31而不是29)瞄准较新的版本)