Найти высоту UIWebView динамически, когда внутри UITableViewCell

У меня есть пользовательский UITableViewCell вот такой

// CustomQuestionCell.h
@interface CustomQuestionCell : UITableViewCell {

    IBOutlet UIWebView *mywebView;

}

-(void) AssignWebView:(NSString *) _text;

// CustomQuestionCell.m
-(void) AssignWebView:(NSString *) _text {

     [mywebView setDelegate:self];
    [mywebView loadHTMLString:_text baseURL:nil];

}

Я могу успешно использовать UITableViewCell в UITableView в файле под названием MainViewController. Делогатом UITableViewCell является CustomQuestionCell. В MainViewController я вызываю следующий код для присвоения значения UIwebview.

// cellForRowAtIndexPath
//CustomQuestionCel.xib uses the class CustomQuestionCell defined above.

CustomQuestionCell *cell = (CustomQuestionCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];

if(cell == nil) {

    [[NSBundle mainBundle] loadNibNamed:@"CustomQuestionCellView" owner:self options:nil];
    cell = tblQuestionCell;
}

[cell AssignWebView:[ListOfQuestions objectAtIndex:indexPath.row]];



return cell;

У меня также есть следующий код делегата в CustomQuestionCell.m

- (void)webViewDidFinishLoad:(UIWebView *)aWebView {
    CGRect frame = aWebView.frame;
    frame.size.height = 1;
    aWebView.frame = frame;
    CGSize fittingSize = [aWebView sizeThatFits:CGSizeZero];
    frame.size = fittingSize;
    aWebView.frame = frame;

    NSLog(@"webview frame size %f",aWebView.frame.size.height);
    [aWebView setOpaque:NO];
    [aWebView setBackgroundColor:[UIColor colorWithRed:249.0/255 green:243.0/255 blue:236.0/255 alpha:1.0]];

    [activityLoad stopAnimating];
    [mywebView setHidden:NO];
}

Моя проблема в том, что я не могу правильно установить высоту ячейки в MainViewController, который имеет tableView, использующий пользовательскую ячейку "CustomQuestionCell". В функции

 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

в MainViewController как я могу установить высоту ячейки как aWebView.frame.size.height ????

10
задан jtbandes 9 July 2011 в 03:58
поделиться