<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UICollectionView/selectItem(at:animated:scrollPosition:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UICollectionView(im)selectItemAtIndexPath:animated:scrollPosition:"
  },
  "title" : "selectItem(at:animated:scrollPosition:)"
}
-->

# selectItem(at:animated:scrollPosition:)

Selects the item at the specified index path and optionally scrolls it into view.

```
func selectItem(at indexPath: IndexPath?, animated: Bool, scrollPosition: UICollectionView.ScrollPosition)
```

## Parameters

`indexPath`

The index path of the item to select. Specifying `nil` for this parameter clears the current selection.

`animated`

Specify <doc://com.apple.documentation/documentation/Swift/true> to animate the change in the selection or <doc://com.apple.documentation/documentation/Swift/false> to make the change without animating it.

`scrollPosition`

An option that specifies where the item should be positioned when scrolling finishes. For a list of possible values, see [`UICollectionView.ScrollPosition`](/documentation/UIKit/UICollectionView/ScrollPosition).

## Discussion

If the [`allowsSelection`](/documentation/UIKit/UICollectionView/allowsSelection) property is <doc://com.apple.documentation/documentation/Swift/false>, calling this method has no effect. If there’s an existing selection with a different index path and the [`allowsMultipleSelection`](/documentation/UIKit/UICollectionView/allowsMultipleSelection) property is <doc://com.apple.documentation/documentation/Swift/false>, calling this method replaces the previous selection.

This method doesn’t cause any selection-related delegate methods to be called.

---

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)