我有一个UITableView
并且想要为将再次出现的行设置动画。我也想在动画之间切换,一些单元格应该得到UITableViewRowAnimationLeft
,而其他UITableViewRowAnimationRight
的。但我不知道如何用我的UITableViewController
. 我尝试将以下代码行插入cellForRowAtIndexPath
:
[self.tableView beginUpdates];
NSArray *updatePath = [NSArray arrayWithObject:indexPath];
[self.tableView reloadRowsAtIndexPaths:updatePath
withRowAnimation:UITableViewRowAnimationLeft];
[self.tableView endUpdates];
不是在单元格中滑动,而是单元格的顺序发生了变化,或者其中一些单元格出现了两次。我还尝试在单元格创建后插入这些行。
if (cell == nil) {
...
} else {
[self.tableView beginUpdates];
NSArray *updatePath = [NSArray arrayWithObject:indexPath];
[self.tableView reloadRowsAtIndexPaths:updatePath
withRowAnimation:UITableViewRowAnimationLeft];
[self.tableView endUpdates];