2012-05-04 51 views
0

我一直在獲取表視圖不一致的異常,想知道一個方法。 點擊表格視圖單元格附件視圖,我在表格視圖中顯示一個額外的單元格,想象一下控制面板彈出您正在查看的行下方。與此同時,對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).'

+0

發佈http回調代碼。看起來它可能會調用reloadData或動畫 – jackslash

+0

此錯誤通常表示您沒有正確管理您的數據源和/或更新後沒有調用重新加載數據。 – TommyG

+0

是的,reloadData正在從http回調代碼中調用,而表視圖是動畫新單元格的動畫。我該如何解決這個問題? – quantumpotato

回答

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

所以裝載電池當它不應該存在的時候,它會堅持到來。