i have collectionView with 52 images in it,
on didSelectItemAtIndexPath
method i have this code:
var cell : UICollectionViewCell = collectionView.cellForItemAtIndexPath(indexPath)!
cell.backgroundColor = UIColor.greenColor()
background color is changing, BUT, when i scroll down my collectionView, another cell there have green background color,
I assume collectionView
doing some redrawing and some strange things happen with indexPath or something,
Could really use advice on how to change color of just one cell, even when you scroll collection view up and down,
Thanks!
D
The cell is getting reused. That's the reason. In your cell class you should add the default background in the prepareForReuse method. Or you can set background in your cellforItemAtIndexPath. The first approach is better.