2

I'm using a WKWebView to load a html resource:

    func setUpWebView() {
    guard let url = Bundle.main.url(forResource: "random", withExtension: "html") else { return }
    let request = URLRequest(url: url)
    webView.load(request)
}

The view is uploading the content of the html resource but is not scaled: view

If I do the same with a UIWebView the resource is scaled (but uiwebview is deprecated)

Any idea?

edit1:

webView.contentMode = .scaleToFill

This doesn't help.

George
  • 328
  • 2
  • 8
  • Can you share code where to add your `webView` please? – vpoltave Nov 19 '19 at 12:48
  • I have solved the issue with this response: https://stackoverflow.com/questions/26102908/suppress-wkwebview-from-scaling-content-to-render-at-same-magnification-as-uiweb – George Nov 19 '19 at 12:53

2 Answers2

1

Try to add some additional settings to webView:

let webConfiguration = WKWebViewConfiguration()

// Make sure your `self.view` already has final size
webView = WKWebView(frame: self.view.bounds, configuration: webConfiguration)
webView.translatesAutoresizingMaskIntoConstraints = false
webView.uiDelegate = self
webView.scrollView.bounces = false

view.addSubview(webView)

I hope it will be useful to you

kzakharc
  • 499
  • 2
  • 8
0

I have solved the problem with this: https://stackoverflow.com/questions...tent-to-render-at-same-magnification-as-uiweb

George
  • 328
  • 2
  • 8