How to fix content getting zoomed in on view rotation Swift 5?

On the first app opening its content is normally fitted to the screen size and on every device rotation it correctly resizes and centers the content. As soon as I zoom in and zoom out and rotate the iPad, the content gets zoomed in and it doesn't fit the view boundaries anymore. I already tried to disable pinch gesture, but then even on the first app opening and view rotation the content gets zoomed in. I also tried detecting orientation with UIDevice.current.orientation.isLandscape and then setting CGRect(x: 0, y: 0, width: viewWidth, height: viewHeight). None of it worked.

Any ideas on how to set the default view size or to zoom out the content on every view rotation?

View setup below

class ViewController: UIViewController, WKNavigationDelegate {

	let webview: WKWebView = WKWebView ()

	private func setupView(){
		webview.frame = view.bounds
		webview.uiDelegate = self
		webview.scrollView.bounces = false
		webview.scrollView.showHorizontalScrollIndicator = false
		webview.scrollView.isScrollEnabled = true
		webview.scrollView.bouncesZoom = false
		webview.autoresizesSubviews = false
		webview.scrollView.contentInsetAdjustmentBehavior = .automatic
		webview.scrollView.maxmumZoomScale = 1.0
		webview.autoresizingMask = [.flexibleHeight, .flexibleWidth]
		view.addSubview(webview)
	}

	override func ViewDidLoad(){
		super.viewDidLoad()
		setupView()
	}
}

I would call

setupView()

in viewWillAppear or viewDidAppear and not (only) viewDidLoad.

How to fix content getting zoomed in on view rotation Swift 5?
 
 
Q