-
Notifications
You must be signed in to change notification settings - Fork 210
Closed
Description
...
private func alignCollectionView(_ collectionView: UICollectionView) {
let centerPoint = CGPoint(x: collectionView.center.x + collectionView.contentOffset.x, y: 50);
if let indexPath = collectionView.indexPathForItem(at: centerPoint) {
// automatically select this item and center it to the screen <<----Not to be selected!
// set animated = false to avoid unwanted effects
collectionView.selectItem(at: indexPath, animated: false, scrollPosition: .top)
if let cell = collectionView.cellForItem(at: indexPath) {
let offset = CGPoint(x: cell.center.x - collectionView.frame.width / 2, y: 0)
collectionView.setContentOffset(offset, animated: false)
}
...
How can I disable automatic selection?
Metadata
Metadata
Assignees
Labels
No labels