Zhen
Zhen

Reputation: 12431

How to make header of a plain UITableView Scroll with the table

I was wondering if there was any way to allow the tableview header of a plain table to scroll with the table?

I am currently using the following method to add my header.

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

Upvotes: 5

Views: 7738

Answers (2)

Ash
Ash

Reputation: 5712

Just use this one self.tableView.tableHeaderView = sectionHeader;

Upvotes: 0

EmptyStack
EmptyStack

Reputation: 51374

Actually the tableHeaderView scrolls with table. This is not the case for section header views. If you have only one section then you can have the header view as tableHeaderView.

table.tableHeaderView = aUiView;

If you have more than one sections and all of them have their own header views, then you have no choice than leaving the header views behave in their own ways. Or, you can imitate the header view by making/configuring/customizing the first row of each section look like header view and remove the actual section header views.

Upvotes: 18

Related Questions