2017-09-06 5 views
0

iOS 11の最新版をテスト中です。アプリ内ブラウザ(WKWebView)でナビゲート中、KVOを使用して進行状況を更新します。残念ながら、100%に達することはありません。ここに私のコードは(iOSの10で完璧に動作します)です:iOS 11 - WKWebView progress KVOが100%に達することはありません

override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) { 

    if keyPath == "estimatedProgress" { 
     print("progres \(webView.estimatedProgress)") 
     if webView.estimatedProgress == 1.0 { 
      print("progress reached 100%") 
      progressView.setProgress(1.0, animated: true) 
      UIView.animate(withDuration: 0.3, delay: 0.3, options: .curveEaseOut, animations: { 
       self.progressView.alpha = 0.0 
      }, completion: { (finished) in 
       self.progressView.setProgress(0.0, animated: false) 
       self.progressView.isHidden = true 
      }) 
     } 
     else { 
      progressView.alpha = 1.0 
      progressView.isHidden = false 
      progressView.setProgress(Float(webView.estimatedProgress), animated: true) 
     } 
    } else if keyPath == "title" { 
     navigationItem.title = webView.title 
    } 
    else { 
     super.observeValue(forKeyPath: keyPath, of: object, change: change, context: context) 
    } 
} 

ここでXcodeのコンソールにどのような印刷出力のサンプルです:調査した後

> progres 0.1 
> progres 0.5 
> progres 0.55430649853092 
> progres 0.771510689002141 
> progres 0.77167516785194 

答えて

0

、問題はCOMPLEXEネットワーク設定から来ているように見えます私が使用している特定の内部URLについてプロキシの使用は問題を解決しました。

関連する問題