I'm building a custom web app and one feature that keeps getting in the way is the "double-tap-to-zoom" on the UIWebView. I've looked on this forum and the web and I don't see an obvious way to disable this.
How can I disable or ignore double-tap-to-zoom in my app?
You simply can disable zooming with putting this code in your viewDidLoad Method:
myWebView.scalesPageToFit = NO;
There is another approach for this. Add this meta tag to the head section of your webView contents:
<meta name="viewport" content="user-scalable=0">
Craig : yo are doing a web app... your code is HTML/Css/Js, I guess.
Solution: use this in
<head></head>
<meta name="viewport" content="user-scalable=0">
Advice You would win if you learn about meta viewport option. Very useful when doing web app for mobiles. Particularly Apple ones.
First option - You can disabled double tap and pinch to zoop by setting this.
_webView.scalesPageToFit = NO;
_webView.multipleTouchEnabled = NO;
Second Option - You can execute the following piece of code in webViewDidFinishLoad to prevent double tap - zoom
NSString *js = @"var metaTag=document.createElement('meta');"
"metaTag.name = \"viewport\";"
"metaTag.content = \"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\";"
"document.getElementsByTagName('head')[0].appendChild(metaTag);";
[webView stringByEvaluatingJavaScriptFromString:js];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With