如何设置iOS WkWebview缩放比例 [英] How to set iOS WkWebview zoom scale

查看:1562
本文介绍了如何设置iOS WkWebview缩放比例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的iOS应用程序具有WKWebView组件,该组件显示的全屏WebApp(1280x800)的宽高比和大小与iPad(4:3,1024x768)不同

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)

我想将WkWebView缩放因子设置为0.8,以使其适合横向模式. 如何控制WkWebView的缩放比例?

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?

我试图设置WkWebView滚动视图的缩放比例,但是即使我相应地设置了minimumZoomScale,它也不能缩放小于1的值.

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?

推荐答案

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

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

它的工作方式就像您在UIWebView中使用了scalePageToFit一样.

It works as if you used scalePageToFit in UIWebView.

这篇关于如何设置iOS WkWebview缩放比例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆