【发布时间】:2016-10-17 08:16:58
【问题描述】:
- (void)registerCellCallBack:(id<CellCallBack>)callBack {
int i = 0;
for(; i < _dataSource.count; ++i) {
id<CellCallBack> oldCallBack = _dataSource[i];
if([callBack key] <= [oldCallBack key]) {
break;
}
}
if(i < _dataSource.count) {
[_dataSource insertObject:callBack atIndex:i];
} else {
[_dataSource addObject:callBack];
}
[self.table beginUpdates];
[self.table insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:i inSection:0]] withRowAnimation:UITableViewRowAnimationNone];
[self.table endUpdates]; //--crashed here called "NSInternalInconsistencyException(SIGABRT)"
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return _dataSource.count;
}
在 iOS9 中运行良好的代码,在 iOS10 中崩溃了,但在我调试代码时没有出现。
崩溃信息:
无效更新:第 0 节中的行数无效。 更新后现有部分中包含的行数 (7) 必须等于该节之前包含的行数 更新(0),加上或减去插入或删除的行数 从该部分(插入 1 个,删除 0 个)并加上或减去数字 移入或移出该部分的行数(0 移入,0 移出)。
【问题讨论】:
-
只删除开始更新和结束更新。就是这样。
标签: ios uitableview