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

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

問題:(刪除tableview中的section時)

 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 (5) must be equal to the number of sections contained in the table view before the update (5), plus or minus the number of sections inserted or deleted (0 inserted, 1 deleted).'

解決:

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

    [self.tableviewdeleteSections:indexset withRowAnimation:UITableViewRowAnimationRight];

    [_arrayTableCellDataremoveObjectAtIndex:row];

    [self.tableviewendUpdates];