UiWebView reset zoom programmatically

旧城冷巷雨未停 提交于 2019-12-21 03:09:11

问题


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


回答1:


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



回答2:


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




回答3:


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;


来源:https://stackoverflow.com/questions/3418547/uiwebview-reset-zoom-programmatically

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