1. 程式人生 > >Invalid update: invalid number of sections. The number of sections contained in the table view afte

Invalid update: invalid number of sections. The number of sections contained in the table view afte

Assertion failure in -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3599.6.1/UITableView.m:1594
2018-09-10 17:34:42.780652 HDBluetoothHelper[1373:639862] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of sections.  The number of sections contained in the table view after the update (1) must be equal to the number of sections contained in the table view before the update (2), plus or minus the number of sections inserted or deleted (1 inserted, 1 deleted).'
*** First throw call stack:
(0x1846d81c0 0x18311055c 0x1846d8094 0x18516282c 0x18a703f64 0x18a700a8c 0x100030da0 0x10005f6b8 0x18a5567b0 0x18a556730 0x18a540be4 0x18a55601c 0x18aae6f30 0x18aae2fc8 0x18aae2ae8 0x18aae1da4 0x18a550d70 0x18a521858 0x18ad0ecb8 0x18ad08720 0x184686278 0x184685bc0 0x1846837c0 0x1845b2048 0x186035198 0x18a58c628 0x18a587360 0x100036eec 0x1835945b8)
libc++abi.dylib: terminating with uncaught exception of type NSException

解決辦法:

[self.tableview beginUpdates];    // 必須新增 開始更新  和結束更新,中間必須刪除 資料

 [self.tableview deleteSections:indexset withRowAnimation:UITableViewRowAnimationRight];    

 [_arrayTableCellData removeObjectAtIndex:row];

 [self.tableview endUpdates];