79194506

Date: 2024-11-16 04:22:17
Score: 1
Natty:
Report link

I ran into this same issue but I believe I found a simpler solution that doesn't involve deactivating and reactivating constraints.

Instead, call setNeedsLayout() from the didFinish navigation delegate method. This triggers another layout pass after the web view has finished loading:

override func viewDidLoad() {
    super.viewDidLoad()

    mainWebView.navigationDelegate = self
    mainWebView.load(URLRequest(url: URL(string: "https://apple.com")!))
}

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
    webView.setNeedsLayout()
}

To ensure you're reliably reproducing the issue, you can slow the simulator animation to ensure the web view loads before the view controller finishes animating on screen.

Thank you @Stefan for pointing me in the right direction!

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Long answer (-0.5):
  • Has code block (-0.5):
  • User mentioned (1): @Stefan
  • Low reputation (0.5):
Posted by: Mel