[英]UITableView scroll animation on reload
I'm trying to animate the content of a tableview right after my data are reloaded. 重新加载数据后,我正在尝试为tableview的内容设置动画。 I succeed by doing this:
我这样做是成功的:
[_tableView reloadData];
[_tableView setContentInset:UIEdgeInsetsMake(-_tableView.contentSize.height, 0, 0, 0)];
[UIView animateWithDuration:kAnimationDuration animations:^{
[_tableView setContentInset:UIEdgeInsetsMake(35, 0, 0, 0)];
[_tableView setContentOffset:CGPointMake(0.0f,-35.f)];
}];
But my animation has not the same speed on different content size (slower or faster). 但是我的动画在不同的内容大小上(慢或快)速度不一样。 How can adjust my speed and have exactly the same animation after each reload ?
每次重新加载后,如何调整速度并获得完全相同的动画?
Set animation duration in proportion to content size of your table view. 根据表格视图的内容大小设置动画持续时间。
[_tableView reloadData];
[_tableView setContentInset:UIEdgeInsetsMake(-_tableView.contentSize.height, 0, 0, 0)];
animationDuration = _tableView.contentSize.height * aConstantK;
[UIView animateWithDuration:animationDuration animations:^{
[_tableView setContentInset:UIEdgeInsetsMake(35, 0, 0, 0)];
[_tableView setContentOffset:CGPointMake(0.0f,-35.f)];
}];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.