UITableViewCell textLabel宽度问题

时间:2010-10-13 00:13:08

标签: iphone

如何限制aCell.textLabel和aCell.detailTextLabel的宽度。我在textLabel中有一个大字符串,它覆盖在我的细节字符串上。我试过这个: aCell.textLabel.width = aCell.width - 250;但它不起作用。任何线索。

2 个答案:

答案 0 :(得分:1)

我不确定这是否是最佳答案,但您可以尝试在界面构建器中创建自定义UITableViewCell。这就是我上次做桌布时不得不做的事情。

DarkDust刚刚在另一个问题上发布了这个教程: http://www.e-string.com/content/custom-uitableviewcells-interface-builder

答案 1 :(得分:1)

我是这样做的:

UILabel *theTitle = [[[UILabel alloc] initWithFrame:CGRectMake(10, 10, 200, 25)] autorelease];                        
  [theTitle setText:[anObject objectForKey:@"key"];              
  [theTitle setFont:[UIFont fontWithName:[self textLabelFont] size:[[self textLabelFontSize] floatValue]]];                 
  [aCell.contentView addSubview:theTitle];