【发布时间】:2012-03-16 13:58:18
【问题描述】:
我有一个带有组样式表的应用程序。
我尝试自定义表头部分:
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 30)];
UILabel *userName = [[UILabel alloc] initWithFrame:CGRectMake (0,0,200,30)];
if (section != 0)userName.text = @"lalala";
[userName setFont:[UIFont fontWithName:@"HelveticaNeue" size:20]];
[headerView addSubview:userName];
[headerView setBackgroundColor:[UIColor clearColor]];
[userName setBackgroundColor:[UIColor clearColor]];
return headerView;
}
但我的标题关闭了单元格:
为什么?
【问题讨论】:
-
仅供参考,您可以使用故事板拖出 UIView 并将其放置为表头。然后将其分配给 IBOutlet。
标签: ios uitableview