views:

85

answers:

1

Hi guys! I'm new to stack overflow and to cocoa-touch developing.

I'm trying to build a UITableViewCell using the UITableViewCellSytleValue2 with a multi-line detailTextLabel.

Therefore I implemented the tableView:heightForRowAtIndexPath: like that:

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

 if (indexPath.row != 4) {
  return tableView.rowHeight;
 }

 NSString *text = toDoItem.note;
 UIFont *font = [UIFont systemFontOfSize:[UIFont systemFontSize]];
 CGSize withinSize = CGSizeMake(167, 1000);
 CGSize size = [text sizeWithFont:font constrainedToSize:withinSize lineBreakMode:UILineBreakModeCharacterWrap];

 CGFloat height = size.height + 26;

    return height;    
}

I figured out the detailTextLabel's width is approximately 167px, but want to know it exactly and don't like it hardcoded (considering orientation changes).

I tried to access the detailTextLabel's frame or bounds, but it returns 0.0 for it's width.

Thanks for your help!

A: 

Create a custom Cell

AWright4911
Thank you for you answer, but actually I just don't want to :-). I can't imagine it is not possible to figure out the width of that label, because it obviously has a fixed width.
nubbel