Question

In my app, I use UIWebviews to display some one page PDFs, I've noticed that in iOS5 the default zoom level is to show the entire document where as in 4.3 the document was opened zoomed in.

Is it possible to programmatically set the zoom level on the UIWebview?

*I've also tried a QLPreviewController and am noticing this same default zoomed out behaviour

Was it helpful?

Solution 2

I got there in the end by looping through the webviews subviews and zooming the scrollview:

    for (UIView *subView in [self.view subviews]) {

        if ([subView isKindOfClass:[UIScrollView class]]) {

            UIScrollView *scrollView = (UIScrollView *)subView;

            [scrollView setZoomScale:2.5f animated:YES];

        }

    }

Its important to note that you need to wait for the webview to render on the screen before attempting to zoom, this caught me out ;-\

OTHER TIPS

Just had the same trouble with setting the zoomScale and no visible respond in the webView. My mistake was to try settings in webViewDidFinishLoad:. The solution is to use viewDidAppear:

-(void)viewDidAppear:(BOOL)animated{
    [self.webView.scrollView setZoomScale:1.5 animated:YES];
}

you can use

webView.scalesPageToFit = NO 
[webView stringByEvaluatingJavaScriptFromString:@"document. body.style.zoom = 5.0;"];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top