Instance Property


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


var allowsSelection: Bool { get set }


If the value of this property is true (the default), users can select items. If you want more fine-grained control over the selection of items, you must provide a delegate object and implement the appropriate methods of the UICollectionViewDelegate protocol.

See Also

Managing the Selection

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.

func deselectItem(at: IndexPath, animated: Bool)

Deselects the item at the specified index.