Hi,
I'm trying to get the current visible cell from my collectionview and call a function based upon the indexPath row value.
I tried to use willDisplayCell but when I added an if else conditional it fired when the cells weren't visible. I also tried
indexPathsForVisibleItems but this too failed to work.The functionality should be when the cell index is 0 run one method else run another.
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
if collectionView == self.locationsCollectionView {
let cell = locationsCollectionView.dequeueReusableCell(withReuseIdentifier: "storedLocationCell", for: indexPath) as! StoredLocationsCell
let storedLocation = storedLocationsData[indexPath.row]
cell.locationCity.text = storedLocation.name?.uppercased()
cell.locationRegion.text = storedLocation.region?.uppercased()
for label in cell.labelSpacing {
label.addTextSpacing(1)
}
cell.locationRegion.textColor = lightGreyColor
return cell
}
}Thanks!