Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (16) must be equal to the number of rows contained in that section before the update (13), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).
下面是網(wǎng)友遇到一種情況孝赫,改成先刪除Model , 再更新就好了
// Editing of rows is enabled
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
//when delete is tapped
[currentCart removeObjectAtIndex:indexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
不過此處我們遇到的一個(gè) BUG 是在 iOS 11 上,在我們所有用戶中一個(gè)月才發(fā)生一次奔潰
[self.tableView beginUpdates];
[self.tableView endUpdates];
當(dāng)然此處直接替換成
[self.tableView reloadData];
當(dāng)然這樣畢竟多走了一些不必要的流程诅愚,如何在不耗流程下解決這個(gè)崩潰呢寒锚?
暫時(shí)沒有重現(xiàn),持續(xù)觀察中违孝。刹前。。