繁体   English   中英

UITableView重新加载时滚动动画

[英]UITableView scroll animation on reload

重新加载数据后,我正在尝试为tableview的内容设置动画。 我这样做是成功的:

[_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)];
}];

但是我的动画在不同的内容大小上(慢或快)速度不一样。 每次重新加载后,如何调整速度并获得完全相同的动画?

根据表格视图的内容大小设置动画持续时间。

[_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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM