Jeremy
Jeremy

Reputation: 883

iOS: Webview not scaling when switching to landscape mode

Since upgrading to Xcode 4.2, web views do not scale correctly when I change orientation

I use this code:

NSLog(@"Show link: %@",URL);

[showStory loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:URL]]];

showStory.scalesPageToFit = YES;

showStory.contentMode = UIViewContentModeScaleAspectFit;

But this happens when I switch to landscape mode. Any suggestions?

enter image description here

Upvotes: 2

Views: 4462

Answers (2)

Vinay Revankar
Vinay Revankar

Reputation: 832

Try this

 webView.scalesPageToFit = YES;
        webView.contentMode = UIViewContentModeScaleToFill;
        webView.multipleTouchEnabled = YES;
        webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        [self.view addSubview:webView];

Upvotes: 3

Clarence
Clarence

Reputation: 1943

You need to tick the scales page to fit option in the webView Attribute inspector.

Upvotes: 0

Related Questions