我的 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;
    }
}