func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if collectionView == thisSeasonCollectionView {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as UICollectionViewCell
let imageView = cell.viewWithTag(1) as! UIImageView
let url = NSURL(string: URLArrayStringThisSeason[indexPath.row])
let placeholderImage = UIImage(named: "Rectangle")!
let filter = AspectScaledToFillSizeWithRoundedCornersFilter(
size: imageView.frame.size,
radius: 0
)
imageView.af_setImage(withURL: url as! URL, placeholderImage: placeholderImage, filter: filter, imageTransition: .crossDissolve(0.2)
)
cell.layer.cornerRadius = 3.0
return cell
}
else if collectionView == whatsNewCollectionView {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as UICollectionViewCell
let imageView = cell.viewWithTag(1) as! UIImageView
let url = NSURL(string: URLArrayStringRecents[indexPath.row])
let placeholderImage = UIImage(named: "Rectangle")!
let filter = AspectScaledToFillSizeWithRoundedCornersFilter(
size: imageView.frame.size,
radius: 0
)
imageView.af_setImage(withURL: url as! URL, placeholderImage: placeholderImage, filter: filter, imageTransition: .crossDissolve(0.2)
)
cell.layer.cornerRadius = 3.0
return cell
}
}
Why doesn't this work? I wish to try to link 3 collection view each from a different tableView Cell to this swift file but it seems like there can only be two. The code works fine if I replace 'else if' with 'else' for some reason.
Edit:
How do I edit the return of cell count:
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
if collectionView == thisSeasonCollectionView {
return URLArrayStringThisSeason.count
}else if collectionView == whatsNewCollectionView {
return URLArrayStringRecents.count
}else if collectionView == labelCollectionView {
return URLArrayStringLabel.count
}
}