title: swift iOS 11.2 WKWebView doesn't show up
body: <p>I'm trying to implement a simple web browser in my application.
  Because I need to control cookies, I decided to go with WKWebView.</p>
  
  <p>The official example works well, but that example 1) doesn't use storyboard 2) sets view to webview directly</p>
  
  <p>So I added my WKWeView to storyboard and connected to an outlet, then loads an URL in <code>viewDidLoad</code>:</p>
  
  <pre><code>class BrowserViewController: UIViewController, WKUIDelegate, WKNavigationDelegate {
  
      @IBOutlet var webView: WKWebView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
          print("browser view loaded")
          webView.uiDelegate = self
          webView.navigationDelegate = self
  
          let myURL = URL(string: "https://www.youku.com")
          let myRequest = URLRequest(url: myURL!)
          webView.load(myRequest)
  
      }
  
  
      override func didReceiveMemoryWarning() {
          super.didReceiveMemoryWarning()
          // Dispose of any resources that can be recreated.
      }
  
  }
  </code></pre>
  
  <p>My Storyboard:</p>
  
  <p><a href="https://i.stack.imgur.com/k2vVtl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k2vVtl.png" alt="storyboard"></a></p>
  
  <p>However, when I run my app in the simulator, the WKWebView does not appear:</p>
  
  <p><a href="https://i.stack.imgur.com/3VDMul.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3VDMul.png" alt="enter image description here"></a></p>
  
  <p>How can I fix this problem? Thanks.</p>
  
  <p><br></p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>This is the layout and constraints of the view</p>
  
  <p><a href="https://i.stack.imgur.com/ik3ngl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ik3ngl.png" alt="enter image description here"></a></p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>So I removed all the unnecessary constraints and the layout seems to be fixed. However, the web view is still blank.</p>
  
  <p>If I add a line <code>view = webView</code> at the end of <code>viewDidLoad</code>. The web page renders correctly. </p>
  
  <p>(For some reason the images would upload, I'll try again later)</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>Unfortunately, move everything to <code>viewWillAppear</code> doesn't work either.</p>
  
  <pre><code>    override func viewWillAppear(_ animated: Bool) {
          super.viewWillAppear(animated)
          print("browser view loaded")
  
          webView.uiDelegate = self
          webView.navigationDelegate = self
  
          let myURL = URL(string: "https://www.bing.com")
          let myRequest = URLRequest(url: myURL!)
          webView.load(myRequest)
      }
  </code></pre>
  
  <p>Webview is still blank.</p>