Objective-c – UITableView section header iOS 5

ios5iphoneobjective cuitableview

I have multiples tables delegated to a UIViewController. In IOS4 I used the function: (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section to change the background of some table header section. In those that do not have sections, I return nil and all works fine.

In IOS5 if I return nil, the system puts one default header section. How do I hide the header section in the tables that I have only one section?

Best Answer

Per the release notes, your UITableViewDelegate MUST now return 0.0 from tableView:heightForHeaderInSection:

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.0;
}

Seems like a real pain. I don't know why they changed this, as everyone relies on the prior behavior - but they must have their reasons.