Zhen Zhen - 1 year ago 60
iOS Question

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

Answer Source

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.