4

To customize cell, we implement class inherit UITableViewCell. Now, to customize header of Section in grouped UITableView (same to below picture), how to do? Please guide to me!
alt text

Community
  • 1
  • 1
hungbm06
  • 1,491
  • 5
  • 22
  • 32

2 Answers2

12

Implement tableView:viewForHeaderInSection: in your table view delegate.

Ole Begemann
  • 132,868
  • 29
  • 267
  • 251
6

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 won't work.

From Apple's reference

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

agarcian
  • 3,831
  • 2
  • 27
  • 53