Created
January 19, 2017 09:09
-
-
Save saitomarch/786dfe963c883c04121ed0b224f8ce80 to your computer and use it in GitHub Desktop.
WKWebView JavaScript Injection to block zoom.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Remember to import WebKit at the top of the file | |
let source = "var meta = document.createElement('meta');" + | |
"meta.name = 'viewport';" + | |
"meta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no';" + | |
"var head = document.getElementsByTagName('head')[0];" + | |
"head.appendChild(meta);" | |
let userContentController = WKUserContentController() | |
userContentController.addUserScript(script) | |
let configuration = WKWebViewConfiguration() | |
configuration.userContentController = userContentController | |
let webview = WKWebView(frame: .zero, configuration: configuration) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment