1
private var webView: WKWebView?

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    webView = WKWebView(frame: .zero)
    guard let webView =  webView else { return }
    webView.translatesAutoresizingMaskIntoConstraints = false
    view.addSubview(webView)
    configureNavBar()
    configureLayouts()
    configureWebView()
}

This crash highlights "view.addSubview(webview)" and tells me it found nil while implicitly unwrapping an optional value. Before I tried making webView non-optional and it yielded the same error. Can someone make sense of this? When I set view = webView and do away with constraints it works fine. Unfortunately I need to add constraints or the nav bar covers the top and it looks terrible. Every attempt to add constraints resulted in various crashes when I've set constraints thousands of times. Don't understand what's happening or how to fix this.

michaeldebo
  • 3,065
  • 4
  • 14
  • 20

0 Answers0