I am using a header view, not section header, w开发者_运维问答ith 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?
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.
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).
精彩评论