Instance Method


Asks the delegate for the height to use for a row in a specified location.


optional func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat



The table-view object requesting this information.


An index path that locates a row in tableView.

Return Value

A nonnegative floating-point value that specifies the height (in points) that row should be.


The method allows the delegate to specify rows with varying heights. If this method is implemented, the value it returns overrides the value specified for the rowHeight property of UITableView for the given row.

There are performance implications to using tableView(_:heightForRowAt:) instead of the rowHeight property. Every time a table view is displayed, it calls tableView(_:heightForRowAt:) on the delegate for each of its rows, which can result in a significant performance problem with table views having a large number of rows (approximately 1000 or more). See also tableView(_:estimatedHeightForRowAt:).

See Also

Configuring Rows for the Table View

func tableView(UITableView, estimatedHeightForRowAt: IndexPath) -> CGFloat

Asks the delegate for the estimated height of a row in a specified location.

func tableView(UITableView, indentationLevelForRowAt: IndexPath) -> Int

Asks the delegate to return the level of indentation for a row in a given section.

func tableView(UITableView, willDisplay: UITableViewCell, forRowAt: IndexPath)

Tells the delegate the table view is about to draw a cell for a particular row.

func tableView(UITableView, shouldSpringLoadRowAt: IndexPath, with: UISpringLoadedInteractionContext) -> Bool

Called to let you fine tune the spring-loading behavior of the rows in a table.