-1

Can someone help me to get rid of the problem of automatic zoom while tying in input field of my website that is shown in WKWebView. I can’t find a solution to this. Please tell me what code to write & where to write to disable zoom while typing in WKWebView.

Arjun Reddy
  • 1
  • 1
  • 1

1 Answers1

1

Try this code , it works for me :

let source: String = "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 script: WKUserScript = WKUserScript(source: source, injectionTime: .atDocumentEnd, forMainFrameOnly: true)
        webView.configuration.userContentController.addUserScript(script)
Vikas Saini
  • 483
  • 4
  • 16