문제

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

도움이 되었습니까?

해결책 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 ;-\

다른 팁

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;"];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top