问题
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?
回答1:
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.
来源:https://stackoverflow.com/questions/54558441/how-to-set-ios-wkwebview-zoom-scale