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.
Asked
Active
Viewed 100 times
-1
-
What kind of zoom? – cora Jun 21 '22 at 14:33
1 Answers
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