以异步方式更新节中的行数

时间:2012-05-04 21:08:26

标签: iphone uitableview

我一直在获得一个表视图不一致异常,希望了解它的方法。 点击表视图单元附件视图,我在表视图中显示另一个单元格,想到一个控制面板弹出正在您正在查看的行下方。同时,对API的HTTP请求正在获取第二页数据..如果在我为控制面板设置动画时数据进入,我就会崩溃。

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

1 个答案:

答案 0 :(得分:0)

解决! 原来这个问题不是直接在内容更新中。我在numberOfRowsInSection中添加了一行,如下所示:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {   
    NSInteger count = [self.sharedItems count];
    if (_contentPagesTotal > _contentPagesLoaded) {
        // Add a row for the loading label
        count++;
    }
    return count;
}

现在是

if (self.showLoadingRow) {
    count ++
}

并在内容http回调中: self.showLoadingRow = _contentPagesTotal> _contentPagesLoaded

所以装载单元在它不应该的时候会粘住。

相关问题