Check if UIWebView is loaded

前端 未结 4 372
陌清茗
陌清茗 2021-02-01 21:19

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

4条回答
  •  悲哀的现实
    2021-02-01 21:34

    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;
    
    }
    

提交回复
热议问题