모든 셀에 웹 뷰가 포함 된 tableview가 있습니다. 모든 셀에 활동 지표를 추가하고 싶습니다. 따라서 웹 뷰가 완료되지 않으면 해당 셀의 특정 활동 표시기가 중단되어야합니다. 물론 내 코드에서 webview delegate는 activityIndicator를 알지 못합니다. 어떻게해야합니까? 고마워.TableViewCell의 evey UIWebView ActivityIndicator
일부 코드 :
- (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;
}
웹보기 대리인 : @pawan이 제안
이- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[activityIndicator stopAnimating];
}
당신이 뭔가를 시도했다 웹뷰 {
}? 여기에 코드를 게시하십시오 – Pawan
몇 가지 코드를 추가했습니다. – tyler
사용자 정의 셀을 만들고 웹 뷰 및 해당 델리게이트를 구현하도록 제안합니다. 여기에서 사용자 정의 셀을 사용할 수 있습니다.이 모든 것을 처리하는 더 좋은 방법입니다. – Pawan