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

# collectionView(_:didSelectItemAt:)

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

## Declaration

```swift
optional func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath)
```

## Parameters

- `collectionView`: The collection view object that is notifying you of the selection change.
- `indexPath`: The index path of the cell that was selected.

## Discussion

Discussion The collection view calls this method when the user successfully selects an item in the collection view. It does not call this method when you programmatically set the selection.

## 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(_:shouldDeselectItemAt:)](uikit/uicollectionviewdelegate/collectionview(_:shoulddeselectitemat:).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)
