Я пытаюсь зафиксировать высоту UILabel в переменной экземпляра.Я использую стиль по умолчанию UITableViewCellStyleValue2
.
. На данный момент я пытаюсь зафиксировать высоту при создании ячейки в
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
коде (пропущендля краткости):
UITableViewCell *testCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:@"myCell"] autorelease];
testCell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap;
testCell.detailTextLabel.numberOfLines = 10;
testCell.selectionStyle = UITableViewCellSelectionStyleNone;
testCell.textLabel.text = @"LabelName";
testCell.detailTextLabel.text = [object valueForKey:@"key"];
[testCell.detailTextLabel sizeToFit]; //still says 0.00 :-(
labelHeight = testCell.detailTextLabel.bounds.size.height;
NSLog(@"testCell height is %f", testCell.detailTextLabel.bounds.size.height); // equals 0.00
NSLog(@"cellFrame is %f", testCell.frame); //also says 0.00
return cell;
NSLog
утверждает, что высота равна 0,00.
Так, где хорошее место, чтобы захватить высоту этикетки?Или что мне не хватает?Я думаю, что detailTextLabel
границы будут установлены, когда я назначу [someObject valueForKey:theKey]
.Спасибо!
РЕДАКТИРОВАТЬ: Для полного кода.