Jim B
Jim B

Reputation: 2277

UITableView Header View Scrolls

I am using a header view, not section header, with my UITableView. The documentation says that the header view sits on top of the table, but my header view scrolls just like a normal row. Is there a way to make the header view always visible at the top of the table?

Upvotes: 3

Views: 11381

Answers (2)

Julijana
Julijana

Reputation: 57

The solution is to implement:

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

and

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

for a fixed header view, not use the self.tableView.tableHeaderView (this one is scrollable).

Upvotes: 4

Mihai
Mihai

Reputation: 741

You certainly did found the solution for this, but I'm posting it here for other people. The table view header and footer views do scroll with the rest of the rows. If you want them to have a fixed position on top, or bottom of the table view then you don't really need a header or footer view. Just add your desired view as a sibling of the table view (subview of tableView's superView) and position it on top or bottom of the tableView.

Upvotes: 6

Related Questions