在iOS 开发过程中,使用最多的控件之一就是UITableView ,UICollectionView相对UITableView用到的就是比较少了,两个控件的刷新估计就不用我费什么话了,下面一句带过
//tableView
[_tableView reloadData];
//collectionView
[_collectionView reloadData];
接下来重点说一下刷新指定的某一 cell,这个用到的地方虽然不如全部刷新的地方多,但是还是会用到,我们下面重点说一下这个方法
首先说一下UITableView
//刷新的位置,第一个参数代表刷新的第几个cell,第二个参数代表的刷新的第几组(一般我们用到一组的情况比较多,所以这里直接我就默认写的0)
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:4 inSection:0];
//开始执行刷新的方法,刷新位置是数组,后面是动画效果,通常默认没有
[_tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
接下来就是UICollectionView,UICollectionView与UITableView类似
//刷新的位置,第一个参数代表刷新的第几个cell,第二个参数代表的刷新的第几组(一般我们用到一组的情况比较多,所以这里直接我就默认写的0)
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:4 inSection:0];
//开始执行刷新的方法,刷新位置是数组,
[_collectionView reloadItemsAtIndexPaths:[NSArray arrayWithObjects: indexPath, nil]];
以上就是UITableView 、UICollectionView的刷新