Hi,
I have my app set up so that auto-rotate works. Things like tableviewcontrollers and tabbarcontrollers automatically resize them selves without the need for me to write any code. However I need my webview etc. to resize when the device is turned to landscape. I set:
webView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
but when I rotate the device it does not resize. I am implementing this incorrectly?
-
I implement the following in my view controller:
- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { [self.webView setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; }Seems to work well.
john : I just tried it there but it doesn't seem to get called when I rotate the simulator. I stuck an NSLOG in there and it's not getting printed.Alex Reynolds : Are you putting this in the view controller? Are you overriding other rotation methods, such as `-shouldAutorotateToInterfaceOrientation:`? -
I think I finally figured this out. It seems that the root view of a NIB file does not allow you to specify flexible width and flexible height for the autoresizing mask in interface builder (at least not as of 3.2). Take a look. Putting the following code in your viewDidLoad seems to fix the problem:
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
I did it after the super call.
0 comments:
Post a Comment