Instance Method

scrollToRow(at:at:animated:)

Scrolls through the table view until a row identified by index path is at a particular location on the screen.

Declaration

func scrollToRow(at indexPath: IndexPath, at scrollPosition: UITableView.ScrollPosition, animated: Bool)

Parameters

indexPath

An index path that identifies a row in the table view by its row index and its section index.

NSNotFound is a valid row index for scrolling to a section with zero rows.

scrollPosition

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

animated

true if you want to animate the change in position; false if it should be immediate.

Discussion

Invoking this method does not cause the delegate to receive a scrollViewDidScroll(_:) message, as is normal for programmatically invoked user interface operations.

See Also

Scrolling the Table View

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

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

enum UITableView.ScrollPosition

The position in the table view (top, middle, bottom) to which a given row is scrolled.