---
title: "collectionView(_:shouldDeselectItemAt:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uicollectionviewdelegate/collectionview(_:shoulddeselectitemat:)"
---

# collectionView(_:shouldDeselectItemAt:)

Asks the delegate if the specified item should be deselected.

## Declaration

```swift
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

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

## Discussion

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

- [Changing the appearance of selected and highlighted cells](uikit/changing-the-appearance-of-selected-and-highlighted-cells.md)
- [Selecting multiple items with a two-finger pan gesture](uikit/selecting-multiple-items-with-a-two-finger-pan-gesture.md)
- [collectionView(_:shouldSelectItemAt:)](uikit/uicollectionviewdelegate/collectionview(_:shouldselectitemat:).md)
- [collectionView(_:didSelectItemAt:)](uikit/uicollectionviewdelegate/collectionview(_:didselectitemat:).md)
- [collectionView(_:didDeselectItemAt:)](uikit/uicollectionviewdelegate/collectionview(_:diddeselectitemat:).md)
- [collectionView(_:shouldBeginMultipleSelectionInteractionAt:)](uikit/uicollectionviewdelegate/collectionview(_:shouldbeginmultipleselectioninteractionat:).md)
- [collectionView(_:didBeginMultipleSelectionInteractionAt:)](uikit/uicollectionviewdelegate/collectionview(_:didbeginmultipleselectioninteractionat:).md)
- [collectionViewDidEndMultipleSelectionInteraction(_:)](uikit/uicollectionviewdelegate/collectionviewdidendmultipleselectioninteraction(_:).md)
