---
title: "scrollToNearestSelectedRow(at:animated:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uitableview/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.

## Declaration

```swift
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 doc://com.apple.uikit/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.

## See Also

### Scrolling the table view

- [scrollToRow(at:at:animated:)](uikit/uitableview/scrolltorow(at:at:animated:).md)
- [UITableView.ScrollPosition](uikit/uitableview/scrollposition.md)
