title: WKWebView didn't finish loading, when didFinishNavigation is called - Bug in WKWebView?
body: <p>Goal: To take a screenshot of WKWebView after the website finished loading</p>
  
  <p>Method employed:</p>
  
  <ul>
  <li>Defined a WKWebView var in UIViewController</li>
  <li><p>Created an extension method called screen capture() that takes image of WKWebView</p></li>
  <li><p>Made my UIViewController to implement WKNavigationDelegate</p></li>
  <li><p>Set the wkwebview.navigationDelegate = self ( in the UIViewController init)</p></li>
  <li><p>Implemented the didFinishNavigation delegation func in UIViewcontroller to call screen capture extension method for WKWebView</p></li>
  </ul>
  
  <blockquote>
  <pre><code>func webView(webView: WKWebView, didFinishNavigation navigation: WKNavigation!) {
      let img = webView.screenCapture()
  }
  </code></pre>
  </blockquote>
  
  <p>Questions:</p>
  
  <ul>
  <li>When I debug i simulator, I notice that the control reaches the didFinishNavigation() func even though the website has not yet rendered in the WKWebView</li>
  <li>Correspondingly the image screenshot taken is a white blob.</li>
  </ul>
  
  <p>What am I missing here? I looked at all possible delegate functions for WKWebView and nothing else seem to represent the completion of content loading in WKWebView. Would appreciate help on if there is a work around</p>
  
  <hr>
  
  <p>Update: Adding screenshot code that I am using to  take a screenshot for web view</p>
  
  <pre><code>class func captureEntireUIWebViewImage(webView: WKWebView) -&gt; UIImage? {
  
      var webViewFrame = webView.scrollView.frame
      if (webView.scrollView.contentSize != CGSize(width: 0,height: 0)){
      webView.scrollView.frame = CGRectMake(webViewFrame.origin.x, webViewFrame.origin.y, webView.scrollView.contentSize.width, webView.scrollView.contentSize.height)
  
      UIGraphicsBeginImageContextWithOptions(webView.scrollView.contentSize, webView.scrollView.opaque, 0)
      webView.scrollView.layer.renderInContext(UIGraphicsGetCurrentContext())
       var image:UIImage = UIGraphicsGetImageFromCurrentImageContext()
       UIGraphicsEndImageContext()
  
       webView.scrollView.frame = webViewFrame         
       return image
      }
  
      return nil
   }
  </code></pre>