UITableView header shows up behind the table


I get this strange thing when I want to create an header to an UITableView.

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;

Can anyone help me?


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.


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


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.