How to set iOS WkWebview zoom scale

生来就可爱ヽ(ⅴ<●) 提交于 2020-05-29 07:35:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!