Instance Property

allowsSelection

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

Declaration

var allowsSelection: Bool { get set }

Discussion

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.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software