iOS UITableview 刷新指定的某一个section或cell

beauty_face.jpg

对于tableView的刷新界面,最简单,最常用的就是

[self.tableView reloadData];

当进行cell上的编辑操作或者某个section的所有cell的reloadData操作,就没有必要全部raloadData,通常减少操作耗损,采用局部reloadData

  1. [Section reloadData]
\\ 类似单选题的多选一、某个section的headerView的大小自适应等,需要重新刷新或布局
NSIndexSet *indexSet = [[NSIndexSet alloc] initWithIndex:indexPath.section];   
[self.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic]; 

2.[Cell reloadData];

// 多选题的当前cell的点击不影响其他cell, cell有textField,textView, button等可编辑点击变化的控件,需要重新刷新或布局 
// 一般不需要这一行
// NSIndexPath *indexPath = [NSIndexPath indexPathForRow:1 inSection:0];    
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone]; 

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容