How to hide UITableView title and then open it again?

I sometimes have a section of my UITableView in which there are no cells contained in this section. In this case, there are two headers on top of each other since there are no cells at the top. I'm trying to figure out how I can temporarily hide this top heading and then reappear when I return to the page later.

Can I return zero for -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section , and then make it call again in viewWillAppear?

Also, if I reload the data using [self.tableView reloadData] , how do you simply return the standard height of the UITableView header?

+6
source share
1 answer

If you need to hide the title

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

If you need to show the title

 [tableView setContentOffset:CGPointMake(0, 0) animated:YES]; 
+13
source

All Articles