You have to use WKWebView to track the loading progress.
First you have to add observers to listen to the progress.
[self.webView addObserver:self forKeyPath:@"loading" options:NSKeyValueObservingOptionNew context:nil];
[self.webView addObserver:self forKeyPath:@"estimatedProgress" options:NSKeyValueObservingOptionNew context:nil];
Then when the web starts loading you handle in this method:
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
if ([keyPath isEqualToString:@"loading"]) {
if (!self.webView.isLoading) {
// Finished loading.
}
}
else if ([keyPath isEqualToString:@"estimatedProgress"]){
float progress = _webView.estimatedProgress; // Do whatever you want with the progress
}
}
In addition, this delegate method gets called when the web view begins loading contents:
- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(null_unspecified WKNavigation *)navigation{
// The web starts loading contents.
}