【发布时间】:2011-05-20 10:21:30
【问题描述】:
我需要插入UILabel 多行文本。我执行以下操作:
NSMutableString * spName = [[NSMutableString alloc ]initWithString:@""];
for (NSUInteger i=0; i<arrEx.count; ++i)
{
ExInfo * exInf = [arrEx objectAtIndex:i];
[spName appendString:[MyObject getName:exInf.spNum]];
[spName appendString:@" "];
[spName appendString:exInf.totalTime];
[spName appendString:@"\n"];
}
CGSize size = [spName sizeWithFont:[UIFont systemFontOfSize:14]
constrainedToSize:constraint
lineBreakMode:UILineBreakModeWordWrap];
[cell.exsInfoLabel setFrame:CGRectMake(CELL_CONTENT_MARGIN, top, CELL_CONTENT_WIDTH - (CELL_CONTENT_MARGIN * 2), size.height)];
[cell.exsInfoLabel setText:spName];
[spName release];
arrEx 由两个项目组成,所以它应该是两个字符串。但是UITableViewCell 只包含第一个字符串。
在 IB 中,我将 UILabel cell.exsInfoLabel 的行数设置为 0。
【问题讨论】: