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

ios, uitableview

Solution

There’s no way to maintain the header of a `tableView` fixed, but an useful approach when you need a unique header, is to use a `UIViewController` rather than a `UITableViewController`, and set the header (`UIView`) out from the `tableView`.

Something like this:

Problem

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 `plain`. But if I use `sections`, 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?

Original source

Related problems