tableview数据源增删,刷新出错问题

来源:互联网 发布:南昌重点高中知乎 编辑:程序博客网 时间:2024/04/27 22:41
*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1914.84/UITableView.m:1037
2012-05-15 22:01:07.800 T_QQList[3933:f803] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0.  The number of rows contained in an existing section after the update (2) must be equal to the number of rows contained in that section before the update (2), plus or minus the number of rows inserted or deleted from that section (0 inserted, 2 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'

是数据源的错误,在列表执行deleteRowsAtIndexPaths时候要求numberOfRowsInSection动态执行,如果定死了的话,则在执行deleteRowsAtIndexPaths的时候还是会返回2行,与删除发生了冲突,报错,所以要动态当没有展开的时候要返回0,展开要为[xxx count].

每次要增删或刷新列表数据源时,要注意改变后的numberOfRowsInSection是否要动态改变.

原创粉丝点击