2013-10-05 76 views
1

TableView由3個部分組成,每個部分都附加到一個數組中,這些數組通過每個單元的附屬視圖中的按鈕相互關聯,因此當按下按鈕時,基礎數據源被更改並且表被重新加載以匹配行的更新前後下面的代碼編號用於:UITableView更新數據源並使用insertRowsAtIndexPaths後重新加載tableview時重複行?

 int sentCount = [[self sendersList] count]; 
     NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0]; 
     NSIndexPath *indexPathToMove = [NSIndexPath indexPathForRow:(sentCount - 1) inSection:2]; 

     [tableView beginUpdates]; 

      [tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPathToMove] withRowAnimation:UITableViewRowAnimationRight]; 

      [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft]; 
     [tableview endUpdates]; 
     [tableview reloadData]; 

我所得到的是原始行的在這個新的indexpath不是細胞本來應該從獲得數據後通過的cellForRowAtIndexPath顯示重複數據源。

我已經記錄並檢查行正在插入的部分被調用適當的次數,但顯示的值是原始單元格的重複副本。

回答

1

核心問題是我在所有三個部分使用相同的單元標識符,當他們有一點點不同的單元部件時,因此儘管有不同的底層數據源,編譯器仍然返回同一單元,解決了我只是使用了不同的單元不同部分的標識符。

相關問題