AJV
AJV

Reputation: 131

How to set iOS WkWebview zoom scale

My iOS app has a WKWebView component which shows an full-screen WebApp (1280x800) with different aspect ratio and size then a iPad (4:3, 1024x768)

I want to set the WkWebView zoom factor to 0.8, to fit it in landscape mode. How can I control the zoom scale of the WkWebView?

I tried to set the the zoom scale of the WkWebView scrollview, but it doesn't scale for values below 1, even when I set the minimumZoomScale accordingly.

[self.webView.scrollView setMinimumZoomScale:0.8];

[self.webView.scrollView setZoomScale:0.8];

Does anyone have an idea why this doesn't work?

Upvotes: 13

Views: 12895

Answers (1)

Jorge A Gomez
Jorge A Gomez

Reputation: 513

Add <meta name="viewport" content="width=device-width, shrink-to-fit=YES"> to your HTML file.

It works as if you used scalePageToFit in UIWebView.

Upvotes: 32

Related Questions