- 刷新cell
NSIndexPath *indexPath=[NSIndexPath indexPathForRow:3 inSection:0];
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationFade];
- 刷新section
NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:2];
[self.tableview reloadSections:indexSet withRowAnimation:UITableViewRowAnimationFade];
查阅了一些资料,对比reloadSections、reloadRows与reloadData的区别。
- 前两者可以加动画,后者不可以。
- 主要是性能的区别:三者的性能在100000次以内,相差无几。
- 数据源动态变化的情况下,例如在某些页面中,每个Section中的row是动态变化的,单独使用reloadSection会导致某些bug。而使用reloadData不会出现这个bug。
- 更多情况下,是搭配beginUpdates和endUpdates来实现 deleteSections:withRowAnimation:的功能。
网友评论