Instance Method


Registers a class for use in creating new table header or footer views.


func register(_ aClass: AnyClass?, forHeaderFooterViewReuseIdentifier identifier: String)



The class of a header or footer view that you want to use in the table (must be a UITableViewHeaderFooterView subclass).


The reuse identifier for the header or footer view. This parameter must not be nil and must not be an empty string.


Before dequeueing any header or footer views, call this method or the register(_:forHeaderFooterViewReuseIdentifier:) method to tell the table view how to create new instances of your views. If a view of the specified type is not currently in a reuse queue, the table view uses the provided information to create a one automatically.

If you previously registered a class or nib file with the same reuse identifier, the class you specify in the aClass parameter replaces the old entry. You may specify nil for aClass if you want to unregister the class from the specified reuse identifier.

See Also

Accessing Header and Footer Views

func register(UINib?, forHeaderFooterViewReuseIdentifier: String)

Registers a nib object containing a header or footer with the table view under a specified identifier.

func dequeueReusableHeaderFooterView(withIdentifier: String) -> UITableViewHeaderFooterView?

Returns a reusable header or footer view located by its identifier.

var tableHeaderView: UIView?

Returns an accessory view that is displayed above the table.

var tableFooterView: UIView?

Returns an accessory view that is displayed below the table.

var sectionHeaderHeight: CGFloat

The height of section headers in the table view.

var sectionFooterHeight: CGFloat

The height of section footers in the table view.

func headerView(forSection: Int) -> UITableViewHeaderFooterView?

Returns the header view associated with the specified section.

func footerView(forSection: Int) -> UITableViewHeaderFooterView?

Returns the footer view associated with the specified section.