码迷,mamicode.com
首页 > 移动开发 > 详细

ios UIWebView支持缩放

时间:2016-04-06 11:23:53      阅读:165      评论:0      收藏:0      [点我收藏+]

标签:

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]];

ios UIWebView支持缩放

标签:

原文地址:http://www.cnblogs.com/Sunnyheart/p/5358227.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!