// UIWebView 缩放
因为写了响应式的界面至页面不能缩放效果
_webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
_webView.scalesPageToFit = YES;
_webView.multipleTouchEnabled = YES;
_webView.userInteractionEnabled = YES;
_webView.scrollView.scrollEnabled = YES;
_webView.contentMode = UIViewContentModeScaleAspectFit;
_webView.delegate = self;
只写增加了这些属性依旧无用..
最后发现是因为html中meta没引用meta的关系.
最后在- (void)webViewDidFinishLoad:(UIWebView *)webView方法中
注入了段js代码.
NSString *jsMeta = [NSString stringWithFormat:@"var meta = document.createElement('meta');meta.content='width=device-width,initial-scale=1.0,minimum-scale=.5,maximum-scale=3';meta.name='viewport';document.getElementsByTagName('head')[0].appendChild(meta);"];
[_webView stringByEvaluatingJavaScriptFromString:jsMeta];