I have a UIViewController
with a UIBarButtonItem
"Edit".When I tap "Edit" I push another controller with some data.I have 2 UICollectionView
inside my controller and they scroll to cells with a specific NSIndexPath
.For example in this image:
It works if I can see cells (from 1.0/5.0 to 2.5/5.0) but if the item of my IndexPath is 6 for example, my collectionView scrolls to the 6th cell (4.0/5.0) but it doesn't select it, and I got this result(as you can see cell's background is not black, so it is not selected):
This is my code:
var index = NSIndexPath(item: indexPathSelected.item, section: 0)
ratingCollectionView.collectionView.selectItem(at: index as IndexPath, animated: true, scrollPosition: .centeredHorizontally)
ratingCollectionView.collectionView(collectionView, didSelectItemAt: index as IndexPath)