Instance Method

tableView:heightForRowAtIndexPath:

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

Declaration

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;

Parameters

tableView

The table-view object requesting this information.

indexPath

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.

Discussion

Override this method when the rows of your table are not all the same height. If your rows are the same height, do not override this method; assign a value to the rowHeight property of UITableView instead. The value returned by this method takes precedence over the value in the rowHeight property.

Before it appears onscreen, the table view calls this method for the items in the visible portion of the table. As the user scrolls, the table view calls the method for items only when they move onscreen. It calls the method each time the item appears onscreen, regardless of whether it appeared onscreen previously.

See Also

Providing Header, Footer, and Row Heights

- tableView:heightForHeaderInSection:

Asks the delegate for the height to use for the header of a particular section.

- tableView:heightForFooterInSection:

Asks the delegate for the height to use for the footer of a particular section.

UITableViewAutomaticDimension

A constant representing the default value for a given dimension.