I want my activity indicator to be displayed until the full web page is loaded.Please help me out with some sample programs or blogs.Thanks
webView = [[UIWebView alloc] initWithFrame:webFrame];
webView.backgroundColor = [UIColor greenColor];
[second.view addSubview:webView];
webView.backgroundColor = [UIColor grayColor];
webView.scalesPageToFit=YES;
[webView release];
NSString *urlAddress = storyLink;
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:requestObj];
[(UIActivityIndicatorView *)[self navigationItem].rightBarButtonItem.customView startAnimating];
I have used the above code inside
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath {}
method.
I have created the activity indicator in the following method
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[super viewWillAppear:YES];
UIActivityIndicatorView * activityIndicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];
UIBarButtonItem * barButton = [[UIBarButtonItem alloc] initWithCustomView:activityIndicator];
[self navigationItem].rightBarButtonItem = barButton;
}
For me activity idicator is created and destroyed within 3 seconds.I want it to be displayed till webpage is fully loaded.Please help me out.Thanks.
First, don't call [super viewWillAppear:] twice. Just call it once. Second, you're leaking activityIndicator and barButton.
You haven't indicated where you've put the stopAnimating call. To do what you've suggested, you'll need to set yourself as the delegate for the webView, and stop the animation in webViewDidFinishLoad:.