这是一个简单的示例(基本上由“Master-Detail”Xcode 模板制作而成)。
我正在尝试在 UITableView 的批量更新中移动一行(“B”)并重新加载另一行(“A1”->“A2”)。
- (void)awakeFromNib
{
[super awakeFromNib];
self.objects = @[@"B", @"A1"];
}
- (IBAction)boom
{
self.objects = @[@"A2", @"B"];
NSIndexPath *path0 = [NSIndexPath indexPathForRow:0 inSection:0];
NSIndexPath *path1 = [NSIndexPath indexPathForRow:1 inSection:0];
[self.tableView beginUpdates];
[self.tableView reloadRowsAtIndexPaths:@[path1] withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView moveRowAtIndexPath:path0 toIndexPath:path1];
[self.tableView endUpdates];
}
Run Code Online (Sandbox Code Playgroud)
这导致以下异常:
2015-01-14 17:58:51.290 batchtest[34004:806671] *** Assertion failure in -[_UITableViewUpdateSupport _setupAnimationsForNewlyInsertedCells], /SourceCache/UIKit_Sim/UIKit-3318.16.14/UITableViewSupport.m:1216
2015-01-14 17:58:51.335 batchtest[34004:806671] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempt to create two animations for cell'
*** First throw call stack: …Run Code Online (Sandbox Code Playgroud)