UITableViewHeaderFooterView Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/UIKit.framework |
| Availability | Available in iOS 6.0 and later. |
| Declared in | UITableViewHeaderFooterView.h |
Overview
The UITableViewHeaderFooterView class implements a reusable view that can be placed at the top or bottom of a table section. You use headers and footers to display additional information for that section.
You can use this class as-is without subclassing in most cases. If you have custom content to display, create the subviews for your content and add them to the view in the contentView property. You can also assign an optional background view to the backgroundView property. Alternatively, if you do not want to add custom subviews, you can use the textLabel and detailTextLabel properties to display some descriptive text in the view.
To make the table view aware of your header or footer view, you need to register it. You do this using the registerNib:forCellReuseIdentifier: or registerClass:forCellReuseIdentifier: method of UITableView.
For information about basic view behaviors, see View Programming Guide for iOS.
Tasks
Initializing the View
Accessing the Content Views
-
contentViewproperty -
backgroundViewproperty
Managing View Reuse
-
reuseIdentifierproperty -
– prepareForReuse
Accessing the Default View Content
-
textLabelproperty -
detailTextLabelproperty -
tintColorproperty
Properties
backgroundView
The background view of the header or footer.
Discussion
The view in this property is placed behind the view in the contentView property and used to display static background content behind the header or footer. For example, you might assign an image view to this property and use it to display a custom background image.
Availability
- Available in iOS 6.0 and later.
Declared In
UITableViewHeaderFooterView.hcontentView
The content view of the header or footer. (read-only)
Discussion
To create your header or footer content, you add subviews to the view in this property. Your custom subviews represent the main content of your header or footer. It is your responsibility to configure all subviews.
Availability
- Available in iOS 6.0 and later.
Declared In
UITableViewHeaderFooterView.hdetailTextLabel
A detail text label for the view. (read-only)
Discussion
Accessing the value in this property causes the view to create a default label for displaying a detail text string. If you are managing the content of the view yourself by adding subviews to the contentView property, you should not access this property.
The label is sized to fit the content view area in the best way possible based on the size of the string. Its size is also adjusted depending on whether there is a primary text label present.
Availability
- Available in iOS 6.0 and later.
Declared In
UITableViewHeaderFooterView.hreuseIdentifier
A string used to identify a reusable header or footer. (read-only)
Discussion
You assign a reuse identifier to a header or footer view at creation time. Once assigned, the table view uses that reuse identifier to gather your views when they are scrolled offscreen and queue them for later reuse. You can retrieve header or footer views by passing the same reuse identifier to the dequeueReusableHeaderFooterViewWithIdentifier: method of the table view.
Availability
- Available in iOS 6.0 and later.
Declared In
UITableViewHeaderFooterView.htextLabel
A primary text label for the view. (read-only)
Discussion
Accessing the value in this property causes the view to create a default label for displaying a detail text string. If you are managing the content of the view yourself by adding subviews to the contentView property, you should not access this property.
The label is sized to fit the content view area in the best way possible based on the size of the string. Its size is also adjusted depending on whether there is a detail text label present.
Availability
- Available in iOS 6.0 and later.
Declared In
UITableViewHeaderFooterView.htintColor
The tint color of the view.
Discussion
The default value of this property is nil.
Availability
- Available in iOS 6.0 and later.
Declared In
UITableViewHeaderFooterView.hInstance Methods
initWithReuseIdentifier:
Initializes a header/footer view with the specified reuse identifier.
Parameters
- reuseIdentifier
A string used to identify the header or footer view if it is to be reused by multiple sections. Pass
nilif the view is not to be reused. You should use the same reuse identifier for all header or footer views of the same form.
Return Value
An initialized UITableViewHeaderFooterView object or nil if the object could not be created.
Discussion
Once set, you cannot change the reuse identifier for the returned view object.
Availability
- Available in iOS 6.0 and later.
Declared In
UITableViewHeaderFooterView.hprepareForReuse
Prepares a reusable header or footer view for reuse by the table.
Discussion
If your header or footer view is reusable—that is, it has a reuse identifier—the table view calls this method just before returning the view from its dequeueReusableHeaderFooterViewWithIdentifier: method. Subclasses can override this method and use it to reset attributes of the view to their default values. For performance reasons, you should only reset attributes that are not related to content.
If the view does not have a reuse identifier, this method is never called.
Availability
- Available in iOS 6.0 and later.
Declared In
UITableViewHeaderFooterView.h© 2012 Apple Inc. All Rights Reserved. (Last updated: 2012-09-19)