The nav bar doesn't resize properly in landsca

2019-08-27 17:44发布

问题:

In IB I created a xib with a navigation bar and a grouped tableview.

In landscape mode, the nav bar doesn't resize properly. I tried to change the autosizing mask. I changed it from IB. For the nav bar, I have set flexible width (red arrow) and the edge distances from superview ones are all set except the bottom margin (no red line, that is flexible bottom margin). For the tableview all lines are red except the top margin (so flexible top margin)... the nav bar resizes, but the two buttons on it don't resize. I tried other combinations, but nothing. This doesn't work for me.

The same thing happens with another xib with a navigation bar, a grouped tableview and an image between them.

Both the views corresponding to these xib are modal.

How could the problem be? I'd prefer to not set them manually. I tried to do it with the modal view with navbar, image and tableview and I don't succeed in doing work it.

Thanks.

回答1:

In IB I removed the navbar and in the code I used:

MyViewController *controller = [[MyViewController alloc]                                 
                              initWithNibName:@"MyViewController" bundle:nil]; 
UINavigationController *innerNav = [[UINavigationController alloc] 
                              initWithRootViewController:controller]; 
[self presentModalViewController:innerNav animated:YES]; 
[controller release]; 
[innerNav release]; 

in this way I've not problems in landscape mode.