I have some VERY simple code to return the title for a section header:
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if (section==0) {
return @"";
} else if (section==1) {
return @"Actions";
} else if (section==2) {
return @"Attached To";
}
return @"";
}
For some reason when the headers are actually displayed on the simulator, half of the time they’re simply the first letter and then ellipses. Scrolling up and down (to refresh the header view most likely) will result in the title showing correctly roughly half the time and showing incorrectly the other half of the time.
Do anyone have any idea what could be causing this? I think this is more of a recent development, but it seems to happen in almost all UITableViews in my application. I don’t want to say this is a 3.2 issue, but it might have started happening around then, but either way it must be related to the code somehow. Thank you.
I’ve figure it out: the actual problem with the code was returning
@"". If you return just a blank string, instead of nil, it will cause a problem with the display of headers and footers.You need to instead return a nil string to get all headers and footers to display correctly. Returning a space
@" "will still leave the vertical space for the header so that is not a viable option. I’ve changed all instances ofreturn @"";to simplyreturn nil;