The first thing I do is to set the cell selected.
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndex
In my case it was caused by using same logic for
func collectionView(_ collectionView: UICollectionView, shouldHighlightItemAt indexPath: IndexPath) -> Bool
as for
func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool
And when cell was selected shouldHighlightItemAt was returning false - and this prevented me to deselect that cell.
Hope this will save someone's time :)