Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide UITableView Header and then have it Reappear?

I occasionally have a section of my UITableView where there are no cells contained in that section. In that case then, there are two headers on top of each other since there are no cells in the upper section. I'm trying to figure out how I can temporarily hide that upper header and then have it reappear when I come back to the page later.

Can I return zero for -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section and then force it to be called again in viewWillAppear somehow??

Also, if I reload the data using [self.tableView reloadData], how do you just return the standard height for a UITableView Header?

like image 654
GoGauchos Avatar asked Jan 03 '13 21:01

GoGauchos


1 Answers

When you have to hide header

[tableView setContentOffset:CGPointMake(0, 44) animated:YES];

When you have to show header

[tableView setContentOffset:CGPointMake(0, 0) animated:YES];
like image 78
Amit Battan Avatar answered Sep 22 '22 18:09

Amit Battan