Why am I getting two section headers on this grouped table?

Posted by Andy on Stack Overflow See other posts from Stack Overflow or by Andy
Published on 2010-04-02T01:13:19Z Indexed on 2010/04/02 1:23 UTC
Read the original article Hit count: 296

Filed under:
|

I'm sure this is some easy-to-fix issue that I've missed, but I can't figure it out. I've got a grouped table view with 3 sections. I'm using the following code to generate section headers:

-(NSString*)tableView:(UITableView*)tableView titleForHeaderInSection:(NSInteger)section {
if (section == 0) {
NSString *header = @"Header 1";
return header;
}
if (section == 1) {
NSString *header = @"Header 2";
return header;
}
else {
NSString *header = @"Header 3";
return header;
}
}

When my table is displayed, there are two headers for each section - one with white text on a gray bar that stretches across the screen (like the letter separators in the Contacts app), and one in gray text on the table background (which is the one I want). Both headers have identical text. Where is the first header coming from?

© Stack Overflow or respective owner

Related posts about iphone-sdk

Related posts about uitableview