【发布时间】:2011-01-19 01:34:07
【问题描述】:
我是意大利人,很抱歉我的“丑陋”英语!
我正在使用 UITableview 并且我的(动态)标题太长了! 所以我想把标题分成两行……有可能吗?
我尝试使用“label.numberOfLines = 2”(或 = 0),但它不起作用!
这是代码:
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
UILabel *label = [[[UILabel alloc] init] autorelease];
label.backgroundColor = [UIColor clearColor];
NSString *header1 = [NSString stringWithFormat:@"Between %@ and %@ \n (33ª and 37ª week)", dateString1, dateString2];
if (section == 0){
label.text = header1;
label.frame = CGRectMake(0, 6, 300, 30);
} else
//the others header
label.numberOfLines = 2;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 30)];
[view autorelease];
[view addSubview:label];
return view;}
谢谢!!
【问题讨论】:
标签: iphone xcode uitableview header uilabel