
UICollectionVIEwCell *cell = [self.collectionVIEw.visibleCells firstObject];
从collectionVIEw中的所有项返回第一项
UICollectionVIEwCell *cell = [self.collectionVIEw cellForItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];
你不想要单元格,只需要数据:
NSIndexPath *indexPath = [[self.collectionVIEw indexPathsForVisibleItems] firstObject];ID yourData = self.dataSource[indexPath.row];
但visivleCells阵列没有订购!
那么,你需要订购它:
NSArray *indexPaths = [self.collectionVIEw indexPathsForVisibleItems];NSSortDescriptor *sort = [NSSortDescriptor sortDescriptorWithKey:@"row" ascending:YES];NSArray *orderedindexPaths = [indexPaths sortedArrayUsingDescriptors:@[sort]];// orderedindexPaths[0] would return the position of the first cell.// you can get a cell with it or the data from your dataSource by accessing .row
编辑:我相信visibleCells(和类似)已经返回订单,但我没有在文档上找到任何相关的内容.所以我添加了订购部分只是为了确保.
总结以上是内存溢出为你收集整理的ios – 有没有办法确定self.collectionview.visiblecells的顺序?全部内容,希望文章能够帮你解决ios – 有没有办法确定self.collectionview.visiblecells的顺序?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)