srk72

fetch images from link asynchronysly in Tableview or CollectionView (Without image show other cell)

Jan 31st, 2022 (edited)
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
  2.  
  3. if collectionView == self.authorList {
  4.  
  5. let imageUrl = authorArray[indexPath.row].image
  6. let cellNot = cell as! CollectionCellSlider
  7.  
  8. if !imageUrl.isEmpty {
  9. cellNot.bookImg.loadImageUsingCache(withUrl: imageUrl)
  10. collectionView.layoutSubviews()
  11. }
  12.  
  13. } else if collectionView == self.popularList {
  14.  
  15. let imageUrl = booksArray[indexPath.row].image
  16. let cellNot = cell as! CollectionCellSlider
  17.  
  18. if !imageUrl.isEmpty {
  19. cellNot.bookImg.loadImageUsingCache(withUrl: imageUrl)
  20. collectionView.layoutSubviews()
  21. }
  22. } else if collectionView == self.editorBookList {
  23.  
  24. let imageUrl = editorBooksArray[indexPath.row].image
  25. let cellNot = cell as! CollectionCellSlider
  26.  
  27. if !imageUrl.isEmpty {
  28. cellNot.bookImg.loadImageUsingCache(withUrl: imageUrl)
  29. collectionView.layoutSubviews()
  30. }
  31.  
  32. } else if collectionView == self.slider {
  33.  
  34. let imageUrl = sliderList[indexPath.row].image
  35. let cellNot = cell as! CollectionCellSlider
  36.  
  37. if !imageUrl.isEmpty {
  38. cellNot.bookImg.loadImageUsingCache(withUrl: imageUrl)
  39. collectionView.layoutSubviews()
  40. }
  41.  
  42. }
  43. }
Add Comment
Please, Sign In to add comment