1

I have a tableview controller and I was trying load a nib for its headerview in the viewdidload. The code is like:

(void)viewDidLoad
{
    [super viewDidLoad];

    self.navigationItem.rightBarButtonItem = self.editButtonItem;


    // Create and set the table header view.
    if (tableHeaderView == nil) {
        [[NSBundle mainBundle] loadNibNamed:@"RZWordDetailHeaderView" owner:self options:nil];
        [tableHeaderView setContentMode:UIViewContentModeScaleAspectFill];

        self.tableView.tableHeaderView = tableHeaderView;
        self.tableView.allowsSelectionDuringEditing = YES;
    }
}

When I run the program, the screen turned out like this image.

It seems that some part of the nib is behind the navigation bar and all the other buttons on the nib view are moved downwards.

Does anyone know how to solve this? Thank you very much.

Andreas
  • 5,393
  • 9
  • 44
  • 53
user2053760
  • 1,673
  • 2
  • 14
  • 19

1 Answers1

0

It doesn't look like tableHeaderView is being set to anything after checking for nil.

Try:

tableHeaderView = [[[NSBundle mainBundle] loadNibNamed:@"RZWordDetailHeaderView"
                                                 owner:self
                                               options:nil] objectAtIndex:0];
Chris Nolet
  • 8,714
  • 7
  • 67
  • 92