iOS 刷新单个Cell

2018-12-21  本文已影响0人  Simon_Liang

在开发过程中,经常遇到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];

上一篇 下一篇

猜你喜欢

热点阅读