当WKWebKit开始加载视频时,试图检测,停止动画

时间:2017-11-16 17:45:33

标签: swift uiwebview wkwebview uiwebviewdelegate

我符合“WKNavigationDelegate”并根据我正在使用的文件 这些方法,但似乎他们没有接到电话。我没有得到任何结果。

func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
    stopAnimating()

    print("didStart Video is loading...")
}

func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) {
    stopAnimating()

    print("Video is loading...")
}

完整的代码,任何正确方向的帮助都会有所帮助,谢谢!

override func viewDidAppear(_ animated: Bool) {
    NVActivityIndicatorView.DEFAULT_BLOCKER_SIZE = CGSize(width: 35, height: 35)
    startAnimating(message:"Loading...", type: .lineScale, color: .lightGray)

    guard let url = holdUrl else {return}

    if let url = URL(string:url) {
        let request = URLRequest(url: url)
        myWebView.load(request)
        myWebView.scrollView.isScrollEnabled = false
    }

1 个答案:

答案 0 :(得分:0)

添加“myWebView.navigationDelegate = self”解决了我的问题...