ios 解决bug(2)---invalid number of rows in section 0. The number of rows contained。。。

来源:互联网 发布:西安定家小酥肉淘宝店 编辑:程序博客网 时间:2024/06/11 13:08

在做UItableview的删除时,报错原因如下

invalid number of rows in section 0.  The number of rows contained in an existing section after the update (8) must be equal to the number of rows contained in that section before the update (8), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'


检查后是由于删除section时多写了两个section删除语句,导致section的索引出错。


解决办法,将其中的一个删除语句注释掉就行

 [tableView deleteSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationLeft];




0 0
原创粉丝点击