swathy
swathy

Reputation:

How to stop loading the UIWebView

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?

Upvotes: 6

Views: 15932

Answers (3)

Sorin Antohi
Sorin Antohi

Reputation: 6135

try something like this:

UIWebView *webView = [self.view viewWithTag:10];
if(webView)
{
    [webView stopLoading];
}

Upvotes: 21

mshau
mshau

Reputation: 503

You can write webView stopLoading method in viewWillDisappear

-(void)viewWillDisappear:(BOOL)animated
{
    if([webView isLoading])
    {
        [webView stopLoading];
    }
}

Upvotes: 6

YSR fan
YSR fan

Reputation: 735

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.

Upvotes: 1

Related Questions