The GroupedTableViewStyle
class has a collection of static utility methods
that create views for headers and footers of a UITableView
with style
UITableViewStyleGrouped
. The returned views have a style consistent with
headers and footers generated by tableView:titleForHeaderInSection:
and
tableView:titleForFooterInSection:
, respectively. The client is then free
to modify these views before displaying them with table sections.
heightForHeaderInSection:
returns the height for the header view of the given section. This method should be delegated to bytableView:viewForHeaderInSection:
.viewForHeaderInSection:withText
returns a view for the header of the given section containing the given text. This method should be delegated to bytableView:viewForHeaderInSection:
. Note that the view returned only supports one line of text; ensuring this is the responsibility of the client.
heightForFooterWithText:isLastSection:
returns the height of the footer view containing the given text, which is also dependent on whether the section is the last section in the table. This method should be delegated to bytableView:heightForFooterInSection:
.viewForFooterWithText:isLastSection
returns a view for the footer containing the given text. This method should be delegated to bytableView:viewForFooterInSection:
.
GroupedTableViewStyleViewController
is a utility program to allow comparing
the appearance of views generated by GroupedTableViewStyle
with headers and footers
generated by tableView:titleForHeaderInSection:
and
tableView:titleForFooterInSection:
, respectively. It also demonstrates the
delegation to GroupedTableViewStyle
discussed above.
At the top of GroupedTableViewStyleViewController
is a value
USE_TITLES_NOT_VIEWS
.
- To display the
UITableView
with titles as headers and footers, set the valueUSE_TITLES_NOT_VIEWS
to1
(true) and then compile and run the program. - To display the
UITableView
with views generated byGroupedTableViewStyle
as headers and footers, set the valueUSE_TITLES_NOT_VIEWS
to0
(false) and then compile and run the program.