As ios documentation says, [webView stopLoading]
method should be used in order to stop webview load task.
As far as I see, this methods runs asynchron
Don't use the UIWebView to download your html document directly.
Use async download mechanism like ASIHTTPRequest to get your html downloaded by a background thread.
When you get the requestFinished
with a content of your html then give it to the UIWebView.
Example from the ASIHTTPRequest's page how to create an asynchronous request:
- (IBAction)grabURLInBackground:(id)sender
{
NSURL *url = [NSURL URLWithString:@"http://allseeing-i.com"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request startAsynchronous];
}
- (void)requestFinished:(ASIHTTPRequest *)request
{
// Use when fetching text data
NSString *responseString = [request responseString];
// Use when fetching binary data
NSData *responseData = [request responseData];
}
- (void)requestFailed:(ASIHTTPRequest *)request
{
NSError *error = [request error];
}
Use the responseString
to your UIWebView's loadHTMLString
method's parameter:
UIWebView *webView = [[UIWebView alloc] init];
[webView loadHTMLString:responseString baseURL:[NSURL URLWithString:@"Your original URL string"]];
This worked for me.
if (webText && webText.loading){
[webText stopLoading];
}
webText.delegate=nil;
NSURL *url = [NSURL URLWithString:@""];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webText loadRequest:requestObj];