commitEditingStyle 错误 invalid number of sections. 错误

删除tableviewcell的时候 出现如下错误

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


原因:数据源中的数据还没有删除,但是tableviewcell已经删除了 所以出错

解决办法:

1.要首先删除数据源中的数据

2.再调用 

[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight];

你可能感兴趣的:(exception,table)