美文网首页
iOS UITableview 刷新指定的某一个section或

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

作者: 这小子 | 来源:发表于2017-11-28 11:41 被阅读484次
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]; 

相关文章

网友评论

      本文标题:iOS UITableview 刷新指定的某一个section或

      本文链接:https://www.haomeiwen.com/subject/nrmsbxtx.html