Class

UITableViewHeaderFooterView

A reusable view that you place at the top or bottom of a table section to display additional information for that section.

Declaration

@interface UITableViewHeaderFooterView : UIView

Overview

Use UITableViewHeaderFooterView objects to manage the header and footer content of your table's sections efficiently. A header-footer view is a reusable view that you can subclass or use as is. To generate a header or footer with a standard appearance, configure the textLabel property with the text you want to display. (If you configured your table view with the group style, you can also configure the detailTextLabel property.) To generate a more custom appearance, add subviews to the view in the contentView property. You can also assign an optional background view to the backgroundView property.

To promote the reuse of your header-footer views, register them by calling the registerClass:forHeaderFooterViewReuseIdentifier: or registerNib:forHeaderFooterViewReuseIdentifier: method of the table view. In the tableView:viewForHeaderInSection: or tableView:viewForFooterInSection: method of your delegate object, call the table view's dequeueReusableHeaderFooterViewWithIdentifier: method to create your view. That method returns a recycled view (if one is available) or creates a new view using the information you registered.

A simple alternative to creating custom header-footer views is to implement the tableView:titleForHeaderInSection: and tableView:titleForFooterInSection: methods of your data source object. When you implement those methods, the table view creates a standard header or footer view and displays the text you supply.

Topics

Creating the View

- initWithReuseIdentifier:

Initializes a header/footer view with the specified reuse identifier.

Managing View Reuse

reuseIdentifier

A string used to identify a reusable header or footer.

- prepareForReuse

Prepares a reusable header or footer view for reuse by the table.

Accessing the Content Views

contentView

The content view of the header or footer.

backgroundView

The background view of the header or footer.

Configuring the Default Content Views

textLabel

A primary text label for the view.

detailTextLabel

A detail text label for the view.

Relationships

Inherits From

See Also

Cells, Headers, and Footers

Configuring the Cells for Your Table

Specify the appearance and content of your table’s rows by defining one or more prototype cells in your storyboard.

Creating Self-Sizing Table View Cells

Create table view cells that support Dynamic Type and use system spacing constraints to adjust the spacing surrounding text labels.

Adding Headers and Footers to Table Sections

Differentiate groups of rows visually by adding header and footer views to your table view’s sections.

UITableViewCell

The visual representation of a single row in a table view.