0

テーブルビューの不整合の例外が発生し、それを回避する方法を知りたいと思っています。テーブルビューのセルアクセサリビューをタップすると、テーブルビューに追加のセルが表示されます。表示している行の下に、コントロールパネルが表示されていると思います。その間、APIへのHTTPリクエストはデータの2ページ目をフェッチしています。コントロールパネルをアニメーション化しているときにデータが入ってくると、クラッシュします。

'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).'

4

1 に答える 1

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

そのため、ロードセルは本来あるべきではないときにくっついていました。

于 2012-05-08T17:27:31.917 に答える