Q:

webView stopLoading issue

I'm trying to implement stop-reload button for a webView.  Here's my code:
- (IBAction)stopOrReloadButtonClick:(id)sender {
    if (self.webView.loading) {
        [self.webView stopLoading];
    }
    else {
        [self.webView reload];
    }
}

and the delegate methods:
- (void)webViewDidStartLoad:(UIWebView *)webView {
    if (indicator ! = nil && indicator.isAnimating == NO) {
        [indicator startAnimating];
    }
    [self.stopReloadButton setImage:[UIImage imageNamed:@"Stop.png"] forState:UIControlStateNormal];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [self.stopReloadButton setImage:[UIImage imageNamed:@"Refresh.png"] forState:UIControlStateNormal];
    [self setNavigationButtonsState];
    [indicator stopAnimating];
}

As you can see the functionality is as follows:
If webView has already loaded content the button is "rounded arrow".  if pressed webView reloads the current page and changes the button image to "cross" that means stop reloading.  And if pressed it should stop reloading page.  When webView finishes loading the image changes to "rounded arrow" again. 
So the problem is if I press "stop" while webView is loading content the correspondent delegate method - (void)webViewDidFinishLoad:(UIWebView *)webView does not get called.  Why ?  And how to implement such functionality? 

A:

This method is called when the web view has finished loading but you are cancelling it won't get called. 
So change your method as 
- (IBAction)stopOrReloadButtonClick:(id)sender {
    if (self.webView.loading) {
        [self.webView stopLoading];
        [self.stopReloadButton setImage:[UIImage imageNamed:@"Refresh.png"] forState:UIControlStateNormal];
        [self setNavigationButtonsState];
        [indicator stopAnimating];

    }
    else {
        [self.webView reload];
    }
}

