tbag
tbag

Reputation: 1278

Zoom UIWebView in iOS7

I have an UIWebView in an iOS 7 app that loads a webpage. I want to set the webview at zoom level 2.0 when the app is launched.

I initialize the webview as

self.view.frame = [[UIScreen mainScreen] applicationFrame];
self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT-66)];
[self.view addSubview:self.webView];
self.webView.scalesPageToFit = YES;
self.webView.backgroundColor = [UIColor clearColor];
self.webView.opaque = NO;

Then in the viewDidAppear method, I set the zoom scale as

UIScrollView *sv = [[self.webView subviews] objectAtIndex:0];
[sv setZoomScale:2.0f];

But it doesn't seem to work. Can someone help me achieve this?

I cannot modify the html as it is an external page.

Upvotes: 0

Views: 388

Answers (1)

Jonathan Ratcliff
Jonathan Ratcliff

Reputation: 26

I don't believe that you can set scalePageToFit = YES and setZoomScale. Try commenting out the scalePageToFit.

Upvotes: 1

Related Questions