2
tebleview에서 사용자 정의 셀의 크기를 조정하려고합니다. 그러나 성공하지 못했습니다. 최종 반환에 NSlog가 :ios7 - boundingRectWithSize : 필요한 레이블 높이를 반환하지 않는 boundingSize
여기2013-12-19 18:51:40.785 DevCloud[15750:70b] 20.281000
2013-12-19 18:51:40.786 DevCloud[15750:70b] 41.565002
2013-12-19 18:51:40.787 DevCloud[15750:70b] 20.281000
2013-12-19 18:51:40.787 DevCloud[15750:70b] 41.565002
세포 및 세포 높이 제 2 방법의 구현이다 : 그것이 작동되도록하는 방법 ? :)
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"TimelineCell";
TLRKTimelineCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
cell.sampleLabel.text = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer fermentum, neque sed viverra vestibulum, arcu ligula imperdiet turpis, blandit consectetur quam neque eu urna. Duis rhoncus accumsan eleifend. Vestibulum ac nunc aliquet, semper felis at, suscipit tortor. Etiam nec mauris nunc.";
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
TLRKTimelineCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TimelineCell"];
CGSize boundingSize = CGSizeMake(cell.sampleLabel.frame.size.width, FLT_MAX);
UIFont *font = [UIFont fontWithName:@"Helvetica Neue" size:17];
CGRect textRect = [cell.sampleLabel.text boundingRectWithSize:boundingSize options:NSStringDrawingUsesFontLeading attributes: @{NSFontAttributeName:font} context:nil];
NSLog(@"%f",textRect.size.height);
NSLog(@"%f",textRect.size.width);
return textRect.size.height;
}
예 : 나는이 자신을 고친다. :). – Aleksandrenko