所以我要将 UITableViewCell
插入到我的 tableView 中。
[searchTableView beginUpdates];
[searchTableView insertRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationTop];
[searchTableView endUpdates];
在此之后,我运行一个异步请求,该请求使用淡入淡出动画更新 tableviewcell。
[someRequestWithCompletion:^(id data) {
dispatch_async(dispatch_get_main_queue(), ^{
[searchTableView beginUpdates];
[searchTableView reloadRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationFade];
[searchTableView endUpdates];
});
}];
但是这个请求有可能在插入动画完成之前完成。如果请求在插入动画之后完成,则没有问题,如果它之前完成并在当前插入的同一单元格上调用 reloadRowsAtIndexPaths
,则该单元格立即显示并在插入时强制重新加载-动画淡出。
有没有办法在cell完全插入后触发reload更新?最好的方法是什么?
如果有任何问题,请在评论中告诉我
最佳答案
试试这个..
您可以在动画完成后重新加载您的 TableView。
[CATransaction begin];
[searchTableView beginUpdates];
[CATransaction setCompletionBlock: ^{
[searchTableView reloadData];
}];
[searchTableView deleteRowsAtIndexPaths: [NSArray arrayWithObjects: indexPath, nil]
withRowAnimation: UITableViewRowAnimationAutomatic];
[searchTableView endUpdates];
[CATransaction commit];
关于iphone - 只有在 Insert-Animation 完成后才重新加载 UITableViewCell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15325092/