iphone - 改变 setContentOffset 的速度 :animated:?

有没有办法在使用 setContentOffset:animated: 滚动 UITableView 时改变动画的速度?我想将它滚动到顶部,但速度很慢。当我尝试以下操作时,它会导致动画开始之前底部的几个单元格消失(特别是滚动完成时不可见的单元格):

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

还有其他方法可以解决这个问题吗?有一个私有(private)方法 _setContentOffsetAnimationDuration 有效,但我不想被应用商店拒绝。

最佳答案

[UIView animateWithDuration:2.0 animations:^{
    scrollView.contentOffset = CGPointMake(x, y);
}];

有效。

https://stackoverflow.com/questions/4404745/

相关文章:

ios - 为什么我的 UIButton 的 "touch up inside"事件没有被调用?

iphone - NSLocale 和国家名称

objective-c - UIAlertController 延迟显示

ios - 为什么 UICollectionView 的 UICollectionViewCell

c - Objective C boolean 数组

ios - Xcode 8 中的单元测试失败

objective-c - 核心数据 : error: Failed to call designa

ios - 显示 UIAlertController 的简单 App Delegate 方法(在 S

ios - 如何将 NSDate 转换为相对格式 "Today","Yesterday","a we

iphone - 滚动后检测 UITableView 中的当前顶部单元格