[英]UICollectionView reload only first cell
I have a collectionView in my app and i want to reload only first cell of collection view. 我的应用程序中有一个collectionView,我只想重新加载集合视图的第一个单元格。 How can i reload only first cell of UICollectionView?
如何仅重新加载UICollectionView的第一个单元格?
You can use reloadItemsAtIndexPaths:
, method of UICollectionView
to reload the first cell. 您可以使用
reloadItemsAtIndexPaths:
方法UICollectionView
重载第一个单元格。
The index path of first cell is row:0 section:0. 第一个单元格的索引路径为row:0 section:0。 NSIndexPath provides a method to create one with a row and a section:
indexPathForRow:inSection:
. NSIndexPath提供了一种创建带有行和节的方法:
indexPathForRow:inSection:
So the way to reload the first cell is: 因此,重新加载第一个单元格的方法是:
[youCollectionView reloadItemsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:0]]];
The above is correct but not indexpath for row . 以上是正确的,但不是row的indexpath。 its a indexpath for item
它是项目的索引路径
collectionView.reloadItems(at:[IndexPath(row:0,section:0)])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.