Created
December 29, 2020 03:18
-
-
Save KrauserHuang/cab3e6fa1226f98554750bc4b270e58d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//照片牆部分 | |
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | |
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: PropertyKeys.imageCell, for: indexPath) as! PostGridCollectionViewCell | |
//將圖片透過data抓下來變成image再回傳給cell | |
if let postImageURL = igposts[indexPath.item].node.thumbnail_src, | |
let url = URL(string: postImageURL) { | |
URLSession.shared.dataTask(with: url) { (data, response, error) in | |
if let data = data { | |
DispatchQueue.main.async { | |
cell.postGridImageView.image = UIImage(data: data) | |
} | |
} | |
}.resume() | |
} | |
return cell | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment