UiWebView 以编程方式重置缩放

发布于 2024-09-13 02:13:01 字数 43 浏览 3 评论 0原文

有没有办法以编程方式缩小或重置 UiWebView ?如果是的话怎么办?

Is there a way to zoom out or reset a UiWebView programmatically ? if yes how ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

っ〆星空下的拥抱 2024-09-20 02:13:03

我认为你应该能够使用 safari 元标记来操作视口

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

例如,要将视口宽度设置为设备的宽度,请将其添加到您的 HTML 文件中:

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

要将初始比例设置为 1.0,请将其添加到您的 HTML 文件中:

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

要设置初始缩放并关闭用户缩放,请将其添加到您的 HTML 文件中:

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

i think you should be able to manipulate the viewport using the safari meta tags

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:

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

To set the initial scale to 1.0, add this to your HTML file:

<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:

<meta name = "viewport" content = "initial-scale = 2.3, user-scalable = no">
南渊 2024-09-20 02:13:03

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

It's not directly supported, but this thread has a workaround/solution.

笑忘罢 2024-09-20 02:13:03

如果您想将用户比例重置为 1.0,至少在 iOS 4.2 上您可以切换 scalesPageToFit

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

If you want to reset the user scale to 1.0, at least on iOS 4.2 you can toggle scalesPageToFit:

webView.scalesPageToFit = NO;
webView.scalesPageToFit = YES;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文