Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

[iPhone]How to customize header of Section in grouped TableView?

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

like image 712
hungbm06 Avatar asked Dec 02 '22 06:12

hungbm06


2 Answers

Implement tableView:viewForHeaderInSection: in your table view delegate.

like image 65
Ole Begemann Avatar answered Feb 22 '23 22:02

Ole Begemann


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.

like image 33
agarcian Avatar answered Feb 22 '23 22:02

agarcian