The only reliable method I found was to listen to three methods that talk about the start of the download, and that it completed the download (plus the equivalent for "failure") and manually checked the count for each.
i.e. something like:
int outstandingRequests; - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { outstandingRequests++; } - (void)webViewDidFinishLoad:(UIWebView *)webView { outstandingRequests--; if( outstandingRequests < 1 ) viewLoadingPleaseWait.hidden = TRUE; } - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { outstandingRequests--; }
I also usually had to overcome the didFail method - Apple is using it incorrectly to report that, for example, a YouTube player took control of a YouTube video. This is NOT a mistake, it is a "page has been loaded by another application."
eg.
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error { outstandingRequests--; if( [error code] == NSURLErrorCancelled ) { NSLog(@"[%@] ...webView CANCELLED loading", [self class] ); } else if( [[error domain] isEqualToString:@"WebKitErrorDomain"] && [error code] == 204) {
Adam Nov 19 2018-10-19 18:56
source share