collectionView(_:shouldSelectItemAt:)
Asks the delegate if the specified item should be selected.
Declaration
optional func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> BoolParameters
- collectionView:
The collection view object that is asking whether the selection should change.
- indexPath:
The index path of the cell to be selected.
Return Value
true if the item should be selected or false if it should not.
Discussion
The collection view calls this method when the user tries to select an item in the collection view. It does not call this method when you programmatically set the selection.
If you do not implement this method, the default return value is true.
See Also
Managing the selected cells
Changing the appearance of selected and highlighted cellsSelecting multiple items with a two-finger pan gesturecollectionView(_:didSelectItemAt:)collectionView(_:shouldDeselectItemAt:)collectionView(_:didDeselectItemAt:)collectionView(_:shouldBeginMultipleSelectionInteractionAt:)collectionView(_:didBeginMultipleSelectionInteractionAt:)collectionViewDidEndMultipleSelectionInteraction(_:)