![](/img/trans.png)
[英]Swift collectionview cant automatically select first cell when load
[英]Swift - how automatically select cell when collectionView first loads up?
我试图弄清楚如何在collectionView启动时以编程方式选择一个单元格。 在中,collectionView的默认负载应该选择第一个单元格。
我正在使用shouldSelectItemAtIndexPath作为我的选择函数,所以我想为特定的单元格索引调用它。
到目前为止,我尝试过:
collectionView(self.collectionView!, shouldSelectItemAtIndexPath: self.collectionView!.indexPathForCell(CVcellArray.first!)!)
在我的viewDidLoad函数中为我的自定义CollectionView脚本。
它在加载collectionView时崩溃了。 难道我做错了什么?
谢谢。
在viewDidAppear
只需调用selectItemAtIndexPath
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.