I have an UIWebView in one tab that loads in viewDidLoad, but if user taps other tab the loading will be disrupted and
- (void)webView:(UIWebView *)webView didFailLoad
It is true that the original question was posted many years ago. Recently I had to find a reliable solution to this issue.
Here is the solution that worked for me:
The complete code is:
- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation{
[webView evaluateJavaScript:@"document.body.innerHTML" completionHandler:^(id result, NSError *error) {
if (result != nil) {
// Call your method here
}
if(error) {
NSLog(@"evaluateJavaScript error : %@", error.localizedDescription);
}
}];
}