更新
我在下面的答案中发布了我的解决方案.我的第一次修订采用了不同的方法.
原始问题 我之前问了一个关于SO的问题我认为我解决了我的问题:
但是,从UITableView中删除部分时,我现在又遇到了类似的问题.(当我改变表格中的部分/行数时,它们重新浮出水面).
在我因为我的帖子的剪切长度而失去你之前,让我清楚地说明问题,你可以尽可能多地阅读以提供答案.
问题:
如果从UITableView批量删除行和部分,应用程序有时会崩溃.这取决于表的配置以及我选择删除的行和部分的组合.
日志说我崩溃了,因为它说我没有正确更新数据源和表:
Invalid update: invalid number of rows in section 5. 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 (1), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 deleted).
Run Code Online (Sandbox Code Playgroud)
现在很快,在你写出明显的答案之前,我向你保证我确实已经从dataSource中正确添加和删除了行和部分.解释很冗长,但您可以按照方法在下面找到它.
那么,如果你仍然感兴趣......
处理部分和行的删除的方法:
- (void)createFilteredTableGroups{
//index set to hold sections to remove for deletion animation …Run Code Online (Sandbox Code Playgroud)