Loading

Tuesday, October 12, 2010

Hide ActivityIndicator When Page DidFinish Loading

1. [WebViewWebDetail loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@""]]];

NSString* WebAddress=[NSString stringWithFormat:@"%@",YourWebAddress];
NSURL* url=[NSURL URLWithString:[WebAddress stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[WebViewWebDetail loadRequest:[NSURLRequest requestWithURL:url]];


2. WEBVIEW Delegate Methods

- (void)webViewDidStartLoad:(UIWebView *)webView
{
Process.alpha=1.0;
Process.hidesWhenStopped = YES;
[Process startAnimating];

}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
if([Process isAnimating])
[Process stopAnimating];
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{

if([Process isAnimating])
[Process stopAnimating];
/*
if (error != NULL) {
UIAlertView *errorAlert = [[UIAlertView alloc]
initWithTitle: [error localizedDescription]
message: [error localizedFailureReason]
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[errorAlert show];
[errorAlert release];
}*/
}

No comments:

Post a Comment