分组表视图顶部空白高度怎么调整



 - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return 0;
    }else
        return 30;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    if (section == 0) {
        return 0;
    }else
        return 30;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return nil;
    }else {
        UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 30)];
        headerView.backgroundColor = [UIColor whiteColor];

        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, 30)];
        [label setText:@"    药品名称       单价         数量     总价   "];
        [headerView addSubview:label];
        return headerView;
    }
}

请输入图片描述
如图和代码,在section0的上面一段空缺灰色的,不知道怎么调整其高度。

ios uitableview objective-c

saria 11 years, 3 months ago
猫耳基德曼 answered 11 years, 3 months ago

Your Answer