Uiwebview scales software

I want to programmatically change the zoom level of the UIWebView.

I tried this, but they do not work for me;

    UIScrollView *sv = [theWebView.subviews objectAtIndex:0];
 [sv setZoomScale:50 animated:YES];

and

  [theWebView stringByEvaluatingJavaScriptFromString:@"document.body.style.zoom = 5.0;"];

Any idea?

+3
source share
3 answers

This is the only way I could find to accomplish this: (specify your own dimensions, if you wanted, I tried to zoom out after entering in the form field)

UIScrollView *sv = [[webViewView subviews] objectAtIndex:0];
[sv zoomToRect:CGRectMake(0, 0, sv.contentSize.width, sv.contentSize.height) animated:YES];
+8
source

I would use:

UIScrollView * sv = self.theWebview.scrollView;

[sv setZoomScale:50];

where selfis it viewControllercontaining webView.

Your problem may be the size of your zoomScaleexceeds the size sv.maximumZoomScale.

+2
source
UIScrollView * sv = yourwebview_outlet.scrollView;
[sv setZoomScale:50];
+1
source

Source: https://habr.com/ru/post/1787534/


All Articles