I´ve got a tableview which contains webviews in every cell. I´d like to add activity indicators for every cell. So whenever a webview didfinishload the specific activity indicator of that cell should stopanimating. Of course the webview delegate down in my code doesn´t know the activityIndicator. How can I do that? Thx.
Some code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nil];
CGRect screenBound = [[UIScreen mainScreen] bounds];
CGSize screenSize = screenBound.size;
CGFloat screenWidth = screenSize.width;
CGFloat screenHeight = screenSize.height;
if (cell == nil) {
NSLog(@"creating a new cell");
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil]autorelease];
[tableView setRowHeight:screenHeight-15];
UIWebView *webview=[[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, screenWidth,screenHeight-95)]autorelease];
webview.delegate = self;
NSURLRequest *nsrequest=[NSURLRequest requestWithURL:[NSURL URLWithString:url]];
[webview loadRequest:nsrequest];
[self.view addSubview:webview];
[cell.contentView addSubview:webview];
UIActivityIndicatorView *activityIndicator = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]autorelease];
activityIndicator.center = CGPointMake(screenWidth/2, (screenHeight/2)-50);
[activityIndicator startAnimating];
[cell.contentView addSubview:activityIndicator];
}
return cell;
}
webview delegate :
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[activityIndicator stopAnimating];
}