UIView autoresizingmask not working for me

I have the application configured, so auto-rotate works. Things like tableviewcontrollers and tabbarcontrollers automatically resize themselves without the need to write any code. However, I need my webview, etc. Changed when the device switched to landscape. I have installed:

webView.autoresizingMask = UIViewAutoresizingFlexibleWidth; 

but when I rotate the device, it does not resize. Am I doing it wrong?

+6
iphone uiviewcontroller uiview
source share
2 answers

I think I finally figured it out. It seems that the root view of the NIB file does not allow you to specify a flexible width and flexible height for the autoresist mask in the interface builder (at least not 3.2). Take a look. I believe the following code in your viewDidLoad fixes the problem:

 self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 

I did this after calling super .

+16
source share

In the view controller, I implement the following:

 - (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { [self.webView setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; } 

Seems to work well.

+4
source share

All Articles