How to stop loading the UIWebView

前端 未结 3 1747
被撕碎了的回忆
被撕碎了的回忆 2021-01-18 10:11

I created number of UIWebviews and add it to my view. And gave load request. I want to stop loading the uiwebview with tag=10. How can this implement?

相关标签:
3条回答
  • 2021-01-18 10:26

    You can stop the UIWebView from loading in UIWebViewDelegate method:

    -(BOOL)webView:(UIWebView*)webView  shouldStartLoadingWithRequest:(NSURLRequest*)request navigationType:(UINavigationType)navigationType
    {
        if(webView.tag==10)
        {
            return  NO;
        }
        return YES;
    }
    

    It will Help you.

    0 讨论(0)
  • 2021-01-18 10:39

    try something like this:

    UIWebView *webView = [self.view viewWithTag:10];
    if(webView)
    {
        [webView stopLoading];
    }
    
    0 讨论(0)
  • 2021-01-18 10:39

    You can write webView stopLoading method in viewWillDisappear

    -(void)viewWillDisappear:(BOOL)animated
    {
        if([webView isLoading])
        {
            [webView stopLoading];
        }
    }
    
    0 讨论(0)
提交回复
热议问题