Instance Method


Deselects the item at the specified index.


func deselectItem(at indexPath: IndexPath, animated: Bool)



The index path of the item to select. Specifying nil results in no change to the current selection.


Specify true to animate the change in the selection or false to make the change without animating it.


If the allowsSelection property is false, calling this method has no effect.

This method does not cause any selection-related delegate methods to be called.

See Also

Managing the Selection

var allowsSelection: Bool

A Boolean value that indicates whether users can select items in the collection view.

var allowsMultipleSelection: Bool

A Boolean value that determines whether users can select more than one item in the collection view.

var indexPathsForSelectedItems: [IndexPath]?

The index paths for the selected items.

func selectItem(at: IndexPath?, animated: Bool, scrollPosition: UICollectionView.ScrollPosition)

Selects the item at the specified index path and optionally scrolls it into view.