title: Detect when WKWebView is finished loading
body: <p>How can I detect when my <code>WKWebView</code> is finished loading so that I can fetch the URL from it such as using the delegate method?</p>
  
  <p>I implemented the delegate method for the <code>WKWebView</code> but I can't detect when it is finish loading the video.</p>
  
  <pre><code>import UIKit
  import WebKit
  
  class ViewController: UIViewController, WKUIDelegate, WKNavigationDelegate {
  
      var webView: WKWebView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
          let preference = WKPreferences()
          preference.javaScriptEnabled = true
          let configuration = WKWebViewConfiguration()
          configuration.preferences = preference
          webView = WKWebView(frame: view.bounds, configuration: configuration)
          view.addSubview(webView)
  
          webView.uiDelegate = self
          webView.navigationDelegate = self
          webView.load(URLRequest(url: URL(string: "http://www.youtube.com")!))
      }
  
      func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
          print("finish loading video")
      }    
  }
  </code></pre>
  
  <p>But the method above is not called when it finishes loading the video from YouTube.</p>
  
  <p>Thank you very much.</p>