我刚开始学习Swift,发现在collectionView中编程选择单元格有些困难。尽管我找到了一些关于tableview的指导,但是实施时还是出错了。
let indexPath = IndexPath(row: 0, section: 0)
appsCollectionView.selectItem(at: indexPath, animated: false, scrollPosition: .bottom)
appsCollectionView.delegate?.collectionView!(appsCollectionView, didSelectItemAt: indexPath)
根据其他答案,您需要使用第2行和第3行。不确定第3行在做什么。当我尝试运行此代码时,出现了错误。
collectionView:didSelectItemAtIndexPath:]: unrecognized selector sent to instance
谢谢!