On a current project we're using the newly introduced (in iOS 8) and mostly awesome
WKWebView to show arbitrary content from around the web. 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.
And the same thing in Swift for funsies: