Comment obtenir la largeur de contenu de UITableViewCell?

J'ai besoin de faire de cellule personnalisé dans UITableViewStyleGrouped table.Il faut regarder comme UITableViewCellStyleValue1 si textLabel et detailTextLabel sont montré sans troncature, ou comme UITableViewCellStyleSubtitle (mais avec detailTextLabel width=contentView.cadre.taille.la largeur et la UITextAlignmentRight) si Valeur1 le style des étiquettes est tronqué.

J'ai besoin de savoir une largeur de cellule.contentView dans la méthode - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath de décider ce que la hauteur de la cellule. Je compare la cellule.contentView.la largeur et la somme des largeurs d'étiquettes (je les reçois l'aide de la méthode sizeThatFits:) de décider.

Donc,Comment obtenir une bonne cellule.contentView.cadre.taille.largeur avant la création des cellules?

UPD: un peu de code pour clarifier la question.

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    CGFloat cellHeight = 44;

    CGSize textSize = [[arrayOfTextData objectAtIndex:indexPath.row] 
                           sizeWithFont:[UIFont systemFontOfSize:14]
                           constrainedToSize:CGSizeMake( 1000, 100)
                           lineBreakMode:UILineBreakModeCharacterWrap];
    CGSize detailedTextSize = [[arrayOfDetailTextData objectAtIndex:indexPath.row] 
                                    sizeWithFont:[UIFont systemFontOfSize:14]
                                    constrainedToSize:CGSizeMake(1000, 100) 
                                    lineBreakMode:UILineBreakModeCharacterWrap];
    if (textSize.width + detailedTextSize.width > /* I need here cell.contentView.frame.size.width*/  300) {
         cellHeight = textSize.height + detailedTextSize.height;
    }
    return cellHeight;
}

UPD2: Le problème est que lorsque je crée de la cellule la cellule.contentView.cadre.taille.la largeur de l'égalité des cellules.cadre.taille.la largeur et de l'égalité des 320, mais après la cellule est apparu cellule.contentView.cadre.taille.la largeur des changements dans la dépendance de la tableView la largeur et la tableView style.

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"tmpCell";
    CustomTableViewCellValue1OrSubtitle *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[CustomTableViewCellValue1OrSubtitle alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];     
    } 
    //--Configure the cell
        cell.textLabel.text = [arrayOfTextData objectAtIndex:indexPath];
        cell.detailTextLabel.text = [arrayOfDetailTextData objectAtIndex:indexPath.row];

    [cell layoutIfNeeded];

    CGSize textSize = [cell.textLabel.text sizeWithFont:cell.textLabel.font constrainedToSize:CGSizeMake(cell.contentView.bounds.size.width, 99999) lineBreakMode:cell.textLabel.lineBreakMode];
    CGSize detailedTextSize = [cell.detailTextLabel.text sizeWithFont:cell.textLabel.font constrainedToSize:CGSizeMake(cell.contentView.bounds.size.width, 99999) lineBreakMode:cell.textLabel.lineBreakMode];
    CGFloat cellHeight = cell.contentView.frame.size.height;

    NSLog(@"contentView.frame.size.width = %f",cell.contentView.frame.size.width);
    //out: contentView.frame.size.width = 320.0
    //Always print 320, even if I set Simulator on iPad

    if (textSize.width + detailedTextSize.width > cell.contentView.frame.size.width) {
        cellHeight = textSize.height + detailedTextSize.height;
    }
    return cellHeight;
}

source d'informationauteur Alexander