Objective c 如何知道UITableView在添加和删除单元格时何时完成动画制作

Objective c 如何知道UITableView在添加和删除单元格时何时完成动画制作,objective-c,ios,Objective C,Ios,我有一个表格,当您选择一个项目时,它会更改该单元格中对象的一些内容,然后将单元格移动到底部,然后重新加载表格数据 //update model ... //move cell to bottom [tableView beginUpdates]; [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationBottom]; [table

我有一个表格,当您选择一个项目时,它会更改该单元格中对象的一些内容,然后将单元格移动到底部,然后重新加载表格数据

//update model
...

//move cell to bottom
[tableView beginUpdates];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationBottom];
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:lastIndex inSection:0]] withRowAnimation:UITableViewRowAnimationTop];
[tableView endUpdates];

//reload cells
[tableView reloadData];

目前,它可以工作,但不会等待动画完成。在重新加载数据之前,如何等待插入和删除动画完成?或者,如果有更好的方法,也很高兴知道。

简单,您可以使用UITableView的
MoveRowatineXpath
来设置单元格从起点到终点的动画,而不是删除单元格然后立即添加新单元格

[tableView moveRowAtIndexPath:[NSArray arrayWithObject:indexPath] toIndexPath:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:lastIndex inSection:0]]];

这简化了前面的部分,但在我重新加载数据时它仍然跳过动画。有没有办法结束动画?@Alex在beginUpdates和endUpdates之间这样做应该可以解决问题,我认为问题在于
[tableView reloadData]的使用。试着把那条线全部移走。