我是堆栈溢出和可可触摸开发的新手。细胞的detailTextLabel的宽度与UITableViewCellStyleValue2风格
我想用多行detailTextLabel使用UITableViewCellSytleValue2构建UITableViewCell。
所以我实现了的tableView:heightForRowAtIndexPath:这样的:
- (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;
}
我想通了detailTextLabel的宽度大约为167px,但是想确切地知道它,不喜欢它硬编码(考虑方向变化) 。
我试图访问detailTextLabel的框架或边界,但它的宽度返回0.0。
感谢您的帮助!
我以200px的字体大小工作。这对我来说工作得很好。 – testing 2010-10-27 10:57:54