How to detect when a UITableView header (table header, not section header) is scrolled off visible area?
Thanks in advance!
How to detect when a UITableView header (table header, not section header) is scrolled off visible area?
Thanks in advance!
There are couple of possible solutions I can think of:
1) You can use this delegate's method:
However, this method is called only if you provide header in the method
You said 'not section header', but you can use the first section header in a grouped tableView as the table headerView. (The grouped is for the header will scroll together with the table view)
2) If you don't want to use grouped tableView and the section header, you can use the scrollView's delegate (UITableViewDelegate conforms to UIScrollViewDelegate). Just check when the tableView is scrolled enough for disappearing the tableHeaderView. See the following code:
Hope it helps.
Here is how a tableView can specify itself whether its
tableViewHeader
is visible or not (Swift 3):