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

# scrollToNearestSelectedRow(at:animated:)

Scrolls the table view so that the selected row nearest to a specified position in the table view is at that position.

```
func scrollToNearestSelectedRow(at scrollPosition: UITableView.ScrollPosition, animated: Bool)
```

## Parameters

`scrollPosition`

A constant that identifies a relative position in the table view (top, middle, bottom) for the row when scrolling concludes. See [`UITableView.ScrollPosition`](/documentation/UIKit/UITableView/ScrollPosition) for a descriptions of valid constants.

`animated`

<doc://com.apple.documentation/documentation/Swift/true> if you want to animate the change in position; <doc://com.apple.documentation/documentation/Swift/false> if it should be immediate.

## Discussion

---

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)