美文网首页
iOS 刷新单个Cell

iOS 刷新单个Cell

作者: Simon_Liang | 来源:发表于2018-12-21 10:18 被阅读0次

在开发过程中,经常遇到tableView数据刷新的情况,,只用更新一行Cell数据时,用[tableview reloadData]来刷新,这样不仅浪费内存,而且有时候还很难达到预期,本文介绍如何刷新固定的某一行的Cell;

如何获取需要刷新Cell的IndexPath信息,请移步链接:http://www.jianshu.com/p/e872225fa860

自定义NSIndexPath的值,代码如下

//section = 0 ,row = 2;

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:2 inSection:0];

调用代码:

//刷新单个cell

[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];

//刷新单个section

NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:indexPath.section]; [tableview reloadSections:indexSet withRowAnimation: UITableViewRowAnimationNone];

相关文章

网友评论

      本文标题:iOS 刷新单个Cell

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