【发布时间】:2013-09-30 22:02:41
【问题描述】:
我的 UITableView 中有 2 个部分。我希望我的第一个标题不存在,没有空间,什么都没有。第一个单元格触摸屏幕顶部。我想要我的第二部分的自定义部分标题。
如果我不使用- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section,我可以这样做,但是当我使用此方法时,第一部分会出现一个空白标题视图。我做错了什么?
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
if (!section == 0){
UIView *header = [[UIView alloc]initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 30.0f)];
UILabel *label = [[UILabel alloc]initWithFrame:[header frame]];
[label setText:@"Test Header"];
[header addSubview:label];
return header;
}
else{
// This apparently causes a header to appear in section 0.
// Without this entire method it works fine- but it means I can't customize
// the header.
return nil;
}
}
【问题讨论】:
标签: objective-c ios uitableview