0
iOS 11의 최신 버전을 테스트하고 있습니다. 인앱 브라우저 (WKWebView)로 탐색하는 동안 KVO를 사용하여 진행 상황을 업데이트합니다. 불행히도 100 %에 이르지 못합니다. 여기iOS 11 - WKWebView 진행 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)
}
}
엑스 코드 콘솔에 인쇄 출력 무엇의 샘플은 다음과 같습니다 : 조사 후
> progres 0.1
> progres 0.5
> progres 0.55430649853092
> progres 0.771510689002141
> progres 0.77167516785194