<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UICollectionViewDelegate/collectionView(_:shouldDeselectItemAt:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UICollectionViewDelegate(im)collectionView:shouldDeselectItemAtIndexPath:"
  },
  "title" : "collectionView(_:shouldDeselectItemAt:)"
}
-->

# collectionView(_:shouldDeselectItemAt:)

Asks the delegate if the specified item should be deselected.

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

<doc://com.apple.documentation/documentation/Swift/true> if the item should be deselected or <doc://com.apple.documentation/documentation/Swift/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 <doc://com.apple.documentation/documentation/Swift/true>.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)