Skip to content

How can I disable automatic selection? #107

@beom-mingyu

Description

@beom-mingyu

...
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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions