- 1
Invalid update: invalid number of rows in section 1. The number of rows contained in an existing section after the update (3) must be equal to the number of rows contained in that section before the update (3), plus or minus the number of rows inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).
我的代碼錯誤原因
// roloadData中描述
You should not call this method in the middle of animation blocks where items are being inserted or deleted. Insertions and deletions automatically cause the table’s data to be updated appropriately.
// 代碼中的邏輯有可能出現(xiàn)下面這種情況
NSMutableArray *indexPathList = [NSMutableArray array];
[indexPathList addObject:[NSIndexPath indexPathForRow:2 inSection:1]];
[self.tableView reloadData];// roloadData在插入赐俗、刪除或者刷新組時調(diào)用回報錯珊燎,導致和numberOfSectionsInTableView:返回不一致,造成閃退
[self.tableView insertRowsAtIndexPaths:indexPathList withRowAnimation:UITableViewRowAnimationAutomatic];