Detecting closest collectionviewcell to the center of the collectionview
问题 Suspect I am doing something fundamentally wrong below... I have a horizontal collectionview and after dragging I want to snap the closest cell to the center. But my results are unpredictable... what am I doing wrong here? func scrollViewDidEndDragging(scrollView: UIScrollView, willDecelerate decelerate: Bool) { // Find collectionview cell nearest to the center of collectionView // Arbitrarily start with the last cell (as a default) var closestCell : UICollectionViewCell = collectionView