On a current project we're using the newly introduced (in iOS 8) and mostly awesome
WKWebView to show custom HTML content. Now for some very specific reasons I can't get into, we need to disable the pinch-to-zoom gesture for all the pages that are displayed.
WKWebView has an
allowsMagnification property to do just this, but unfortunately this and the other properties that allow you to modify the magnification are only available on OS X.
meta tag that disables scaling of the
viewport and inject it into the document's
WKUserScript object which we tell the
WKUserContentController to always inject into loaded pages, and pass that controller to a
WKWebViewConfiguration object, which is used when we create our
That sounds like a mouthful but its quite straightforward. Paste code the code below into a
viewDidLoad method to try it out.
UPDATE: Initially I had written that we were loading arbitrary content from around the web which wasn't strictly the case and also caused a few people to suggest that this was a bad thing. Absolutely 100% agree. However in this specific case we are loading custom content, produced in-house and requires the gesture to be disabled.
Otherwise you probably should never do this.