views:

78

answers:

1

I add a navigationbar, a webview and a toolbar(from top to bottom) as subviews of my viewcontroller's view. I want the navigationbar and toolbar's height shrink a little in landscape orientation so I use autoresizingmask to make the height flexible. (UIViewAutoresizingFlexibleHeight will make navigationbar and toolbar's height shrink from 44 to around 30):

webNavBar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin;
webToolBar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin;
webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

Now I found that when I rotate the device to landscape mode, there will be two blank white bars on the top and bottom of the webview(each blank bar's height is 44-30). Navigationbar and toolbar appear to be in the correct position. Is there any way to resize the webview and fill the gaps?

A: 

Are you sure the Autoresizing margins are set correctly for the webview? could always do:

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
   webView.frame = self.view.frame;
}

No idea if that will work but worth a shot.

swaterfall
Thanks for your answer but the webview is not a full screen view. Anyway, you give me an idea that I may reset its frame to get a correct size.
iPhoney