Reputation: 273
I have a custom view that I'm trying to load into a tableViewHeader. The strange thing is that the bottom of the background is always getting cut off. It's as if the nav bar is pushing the buttons down, but not the rest of the view.
The nib looks like this:
I'm setting it like this in my tableviewcontroller:
[[NSBundle mainBundle] loadNibNamed:@"MenuNav" owner:self options:nil];
[self.tableView setTableHeaderView:headerView];
This is what it looks like in the simulator. The buttons are also not handling clicks in the bottom half.
What I have tried: -bringing the subview to the front:
[self.tableView bringSubviewToFront:headerView];
-setting needs layout for the tableview:
[self.tableView setNeedsLayout]
-I have also checked that the view's frame is correct.
Any Ideas? thanks!
I found the culprit. I had to uncheck Autoresize Subviews in IB: https://i.sstatic.net/8I2NS.png
Upvotes: 3
Views: 1194
Reputation: 443
Maybe you could try:
to return your view and the methods that Jacky Boy say to return the header height:
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
Upvotes: 1
Reputation: 11537
Did you try by playing with the autoresizingMask of your view? I will add something like this to your code:
headerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
Upvotes: 0