【发布时间】:2012-03-27 09:55:11
【问题描述】:
我使用了 insertRowsAtIndexPath 而不是 reloadData。 第一次加载时,动画太快了,因为行数太多了。
insertRowsAtIndexPath 的动画速度可以控制吗?
谢谢。
【问题讨论】:
标签: ios uitableview
我使用了 insertRowsAtIndexPath 而不是 reloadData。 第一次加载时,动画太快了,因为行数太多了。
insertRowsAtIndexPath 的动画速度可以控制吗?
谢谢。
【问题讨论】:
标签: ios uitableview
我认为无法控制动画速度。
也许您可以改用scrollToRowAtIndesPath。
【讨论】:
覆盖 insertRowsAtIndexPaths 并添加您喜欢的自定义动画延迟。
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation: (UITableViewRowAnimation)animation
{
for (NSIndexPath *indexPath in indexPaths)
{
UITableViewCell *cell = [self cellForRowAtIndexPath:indexPath];
[cell setFrame:CGRectMake(320, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height)];
[UIView beginAnimations:NULL context:nil];
[UIView setAnimationDuration:1];
[cell setFrame:CGRectMake(0, cell.frame.origin.y, cell.frame.size.width, cell.frame.size.height)];
[UIView commitAnimations];
}
}
【讨论】:
绝对未经测试,但您可以尝试 5 秒动画:
[UIView animateWithDuration:5. animations:^(void){
[_tableView insertRowsAtIndexPath:... animated:NO];
}];
【讨论】: