2013-10-05 75 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

核心问题是我在所有三个部分使用相同的单元标识符,当他们有一点点不同的单元部件时,因此尽管有不同的底层数据源,编译器仍然返回同一单元,解决了我只是使用了不同的单元不同部分的标识符。

相关问题