简体   繁体   English

UiWebView以编程方式重置缩放

[英]UiWebView reset zoom programmatically

Is there a way to zoom out or reset a UiWebView programmatically ? 有没有办法以编程方式缩小或重置UiWebView? if yes how ? 如果有,怎么样?

i think you should be able to manipulate the viewport using the safari meta tags 我认为你应该能够使用safari元标记来操纵视口

https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html#//apple_ref/doc/uid/TP40008193-SW6 https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html#//apple_ref/doc/uid/TP40008193-SW6

For example, to set the viewport width to the width of the device, add this to your HTML file: 例如,要将视口宽度设置为设备的宽度,请将其添加到HTML文件中:

<meta name = "viewport" content = "width = device-width">

To set the initial scale to 1.0, add this to your HTML file: 要将初始比例设置为1.0,请将其添加到HTML文件中:

<meta name = "viewport" content = "initial-scale = 1.0">

To set the initial scale and to turn off user scaling, add this to your HTML file: 要设置初始比例并关闭用户缩放,请将其添加到HTML文件中:

<meta name = "viewport" content = "initial-scale = 2.3, user-scalable = no">

它不是直接支持的,但是这个线程有一个解决方法/解决方案。

If you want to reset the user scale to 1.0, at least on iOS 4.2 you can toggle scalesPageToFit : 如果要将用户比例重置为1.0,至少在iOS 4.2上可以切换scalesPageToFit

webView.scalesPageToFit = NO;
webView.scalesPageToFit = YES;

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

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