无效更新:部分中的行数无效

时间:2017-07-03 21:51:15

标签: ios uitableview uikit

我收到此错误消息,我无法弄清楚该做什么或如何调试:

'无效更新:第1部分中的行数无效。更新后的现有部分中包含的行数(7)必须等于该部分中包含的行数。更新(7),加上或减去从该部分插入或删除的行数(插入0,删除1),加上或减去移入或移出该部分的行数(0移入,0移出)。 '

我的桌子上有3个部分。这是在我的数据源发生任何变化之前,每个部分中的行数:

// Check current data source
date source for section 0: 1 items
data source for section 1: 8 items
data source for section 2: 8 items

sections count: 3
section 0 1 rows
section 1 8 rows
section 2 8 rows

以下是从第1部分删除行后打印出的内容,我想将其移至第2部分:

// Updated my date source
date source for section 0: 1 items
data source for section 1: 7 items
data source for section 2: 9 items

sections count: 3
section 0 1 rows
section 1 7 rows
section 2 9 rows

// Then the crash message happen

请帮忙。感谢。

1 个答案:

答案 0 :(得分:2)

在调用deleteRowsAtIndexPaths:withRowAnimation之前,需要从数据数组中删除该对象。

Basically the same question in stackoverflow

相关问题