UITableView header shows up behind the table


#1

I get this strange thing when I want to create an header to an UITableView.
http://i.imgur.com/hfnDDhu.png?4100

My code creating the header looks like this:

[code]-(UIView *)tableView:(UITableView *)tv viewForHeaderInSection:(NSInteger)sec {

return [self headerView];
}

  • (CGFloat)tableView:(UITableView *)tv heightForFooterInSection:(NSInteger)sec {

NSLog(@"%f",[[self headerView] bounds].size.height);
return [[self headerView] bounds].size.height;
}

-(id)initWithStyle:(UITableViewStyle)style {

return [self init];
}

-(UIView *)headerView {

//Falls headerView noch nicht geladen wurde …
if (!headerView) {
//Lädt headerview.xib
[[NSBundle mainBundle] loadNibNamed:@“HeaderView” owner:self options:nil];
}
return headerView;
}[/code]

Can anyone help me?


#2

I imagine you are past this, but it should be:

Header, not footer. This tripped me up as well, so leaving this here for posterity.


#3

I can’t believe I made the same mistake. Thanks for the help :slight_smile:


#4

I hit exactly the same issue. XCode’s autocomplete has caught me out a few times since I have been working through the book, but I usually spot them fairly quickly.

This one sneaked past and I didn’t pick it up even after multiple reviews agains the code in the text.