UITableView Header Scroll

I use the title, not the section title, with my UITableView. The documentation says that the header view is on top of the table, but my header view scrolls just like a regular row. Is there a way to make the header look always visible at the top of the table?

+3
source share
2 answers

Of course, you have found a solution for this, but I am posting it here for other people. The table header and footer views scroll with the rest of the rows. If you want them to have a fixed position on the top or bottom of the table view, you really don't need the view of the header or footer. Just add the desired view as a child of the tableview (subview of tableView superView) and place it above or below the tableView.

+6
source

The solution is to implement:

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

and

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

for a fixed header, do not use self.tableView.tableHeaderView (this one scrolls).

+4
source

Source: https://habr.com/ru/post/1748903/


All Articles