Instance Method

collectionView(_:shouldDeselectItemAt:)

Asks the delegate if the specified item should be deselected.

Declaration

optional func collectionView(_ collectionView: UICollectionView, shouldDeselectItemAt indexPath: IndexPath) -> Bool

Parameters

collectionView

The collection view object that is asking whether the selection should change.

indexPath

The index path of the cell to be deselected.

Return Value

true if the item should be deselected or false if it should not.

Discussion

The collection view calls this method when the user tries to deselect an item in the collection view. It does not call this method when you programmatically deselect items.

If you do not implement this method, the default return value is true.

See Also

Managing the Selected Cells

func collectionView(UICollectionView, shouldSelectItemAt: IndexPath) -> Bool

Asks the delegate if the specified item should be selected.

func collectionView(UICollectionView, didSelectItemAt: IndexPath)

Tells the delegate that the item at the specified index path was selected.

func collectionView(UICollectionView, didDeselectItemAt: IndexPath)

Tells the delegate that the item at the specified path was deselected.