I have UIViewControllerwith a few built in it UITableView. For some tables, I need to show my own header view with several labels. For other tables, I don’t want to show the title at all (i.e. I want the first cell in to myTable2be at the top of the frame for myTable2). Here is roughly what I have:
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if (tableView == self.myTable1)
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0,tableView.contentSize.width,20);
return view;
}
elseIf (tableView == self.myTable2)
{
return nil;
}
}
This works great for custom headers, but for tables where I don't need a heading, it shows a white box. I figured it return nil;would prevent any header from being displayed for this table. Is this assumption correct? Is there anything else that rewrites this? How can I make sure that nothing is shown?