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 didFailLoadWithError:(NSError *)error
will be called, but I want to know how can check if webView is loaded if user taps the previous tab again, and if it's not loaded it will reload it, something like this
-(void)viewWillAppear:(BOOL)animated
{
if (!webView)
{
NSURL *url = [NSURL URLWithString:@"url"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView loadRequest:request];
}
}
But it's not working, help please?
UIWebview has a webViewDidFinishLoad delegate method. Set a bool to indicate this was done.
- (void)webViewDidStartLoad:(UIWebView *)webView {
webViewDidFinishLoadBool = NO;
loadFailedBool = NO;
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
loadFailedBool = YES;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
if (!loadFailedBool)
webViewDidFinishLoadBool = YES;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With