I have a strange problem when tapping a single UICell in UICollectionView and then scrolling down or up in the UICollectionView I see that more one cell is selected. The other cells that are selected that were not tapped seem to be randomly selected throughout the UICollectionView layout. I have 3 columns of cells and many rows in the UICollectionView.
In my code I have the following:
- (void)collectionView:(UICollectionView *)myCV didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
LogInfo(@"Item Selected");
// highlight the cell user tapped on
UICollectionViewCell *cell = [myCV cellForItemAtIndexPath:indexPath];
[cell.layer setBorderWidth:10.0f];
cell.layer.borderColor = [UIColor colorWithRed: 108/255. green: 166/255. blue: 16/255. alpha:1.0].CGColor;
cell.layer.CornerRadius = 10;
}
The highlight code just puts a border on the tapped cell.
Is there a way to make sure that only the cell that is tapped is selected?