Hide Views Function got called on cells that i dont want

36 Views Asked by At

In my CollectionView I am trying to hide content of cells which indexPath is more than 0, by calling blockContent func on cell. But somehow, after going back and forth threw cells, this func got called even on the first cell. How can i Fix it? Thanks

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
    guard let cell = collectionView.dequeueReusableCell(withReuseIdentifier: cellId, for: indexPath) as? InsightCollectionViewCell else { return UICollectionViewCell()}
    
    if indexPath.item > 0 {
        cell.blockContentWithSpoiler()
        cell.delegate = self
    }
    
    return cell
}

Tried to use cell.prepareForReuse() but that didnt help...

0

There are 0 best solutions below