[IPhone] How to set up a section title in a grouped TableView?

To customize the cell, we implement the inheritance of the UITableViewCell class. Now, to set up the section title in a grouped UITableView (same as below), how to do it? Please guide me! alt text

+4
source share
2 answers

Add tableView:viewForHeaderInSection: to the table view delegate.

+12
source

Starting with iOS 5 you also need to implement

 - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 

In addition to

 - (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 

Otherwise it will not work.

From Apple Link

The returned object may be a UILabel or UIImageView object, as well as a custom view. This method only works correctly when tableView: heightForHeaderInSection: is also implemented.

+6
source

All Articles