简体   繁体   English

如何设置 iOS WkWebview 缩放比例

[英]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)我的 iOS 应用程序有一个 WKWebView 组件,它显示一个全屏 WebApp (1280x800) 与 iPad (4:3, 1024x768) 不同的纵横比和大小

I want to set the WkWebView zoom factor to 0.8, to fit it in landscape mode.我想将 WkWebView 缩放系数设置为 0.8,以适应横向模式。 How can I control the zoom scale of the WkWebView?如何控制 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.我试图设置 WkWebView 滚动视图的缩放比例,但它不会缩放小于 1 的值,即使我相应地设置了 minimumZoomScale。

[self.webView.scrollView setMinimumZoomScale:0.8];

[self.webView.scrollView setZoomScale:0.8];

Does anyone have an idea why this doesn't work?有谁知道为什么这不起作用?

Add <meta name="viewport" content="width=device-width, shrink-to-fit=YES"> to your HTML file.<meta name="viewport" content="width=device-width, shrink-to-fit=YES">到您的 HTML 文件中。

It works as if you used scalePageToFit in UIWebView.它的工作原理就像您在 UIWebView 中使用 scalePageToFit 一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM