webView height should change when transitioning to landscape

169 Views Asked by At

In need of some help here, please.

I have this webView that loads a html text. The webview is inside a scrollView below other elements(an image, a stack view). I set its height like this

func webViewDidFinishLoad(_ webView: UIWebView) {
    heightWebView.constant = webView.scrollView.contentSize.height
}

Everything is fine when I enter the view controller and scroll through it, but when I change from Portrait to Landscape, I do not have enough space in the scroll view to scroll the whole webView and the inscroll of the Webview activates.

Any ideea what I should do? I already tried in

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {

to reset the height of the webView like in webViewDidFinishLoad, but it didn't work.

0

There are 0 best solutions below