Houman Houman - 5 months ago 31
iOS Question

Is it possible to have a fixed uitableview Header while using sections?

This question should not be mixed up with this here.. These are two different things.

There is a good example how to use a UITableView Header on SO.

This all works fine and the main header is fixed on top as long as the style is set to


But if I use
, the main header no longer sticks to top and moves away while scrolling to the bottom.

In this method, I am returning the header for each section.

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

In this method I am setting the height for the header section above:

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

In this method, I am setting the real table header.

- (void)viewWillAppear:(BOOL)animated {
self.recordTableView.tableHeaderView = headerView;

Is it even possible having a fixed table header, while using sections?
What is an alternative solution to this please?


There is not a way to maintain the header of a tableView fixed, but an useful approach when you need a unique header, could be use an UIViewController instead that an UITableViewController, and set the header (UIView) out from the tableView.

Something like this:

enter image description here