[英]how do I change an image by selecting a cell in CollectionView
如果每個圖像都在單獨的UICollectionViewCell中,請使用
override func collectionView(_ collectionView: UICollectionView,
didSelectItemAt indexPath: IndexPath) {
// here you know which item is selected by accessing indexPath.item property, for example:
let selectedImage = yourImages[indexPath.item]
bigImageView.image = selectedImage
}
檢測用戶何時選擇集合視圖項的方法。 為了使用此方法,您需要遵循UICollectionViewDelegate
並設置collectionView.delegate = self
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.