【发布时间】:2010-02-24 09:46:01
【问题描述】:
我有一个包含不同条目的表格,每个条目的长度不同。每行的高度应该适合,所以它可以显示整个字符串。
我使用以下代码:
//... cellForRowAtIndexPath
if (row == 0) {
cell = [tableView dequeueReusableCellWithIdentifier:@"affCell"];
//if (!cell) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"affCell"]autorelease];
cell.accessoryType = UITableViewCellAccessoryNone;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.autoresizingMask = UIViewAutoresizingFlexibleHeight;
affL = [[UILabel alloc] initWithFrame:CGRectZero];
affL.textAlignment = UITextAlignmentLeft;
affL.autoresizingMask = UIViewAutoresizingFlexibleHeight;
[cell.contentView addSubview:affL];
//}
//declaration label
affL.text = [fDictionary objectForKey:@"aff"];
affL.numberOfLines = 0;
[affL sizeToFit];
affL.frame = CGRectMake(15.0, 10.0, 220.0, affL.frame.size.height);
CGFloat affLH = affL.frame.size.height;
[tableView setRowHeight:affLH+30];
我也用
//... heightForRowAtIndexPath
return affL.frame.size.height;
我该如何解决这个问题?
【问题讨论】:
标签: iphone cocoa-touch uikit uitableview