我是堆棧溢出和可可觸摸開發的新手。細胞的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