ios UIWebView支持缩放
1.定义一个宏:该宏js代码可以使加载的网页支持缩放功能
- 注意标红属性的功能
#define QUOTE(...) #__VA_ARGS__
const char *webViewHeightJSString = QUOTE(
var viewportmeta = document.querySelector('meta[name="viewport"]');
if (viewportmeta) {
viewportmeta.content = 'width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=4.0, user-scalable=yes';
}
);
#undef QUOTE
2.在webview成功加载后,执行该段js代码
[webView stringByEvaluatingJavaScriptFromString:[NSString stringWithUTF8String:webViewHeightJSString]];