简体   繁体   中英

section headers for only some sections in grouped uitableview

I changed my UITableView to grouped (so the sections will scroll with the content).

The thing is - that some of the sections have no header (nil view, 0.01 height - as I read I should do)

There is still a gap between the sections.

How can I avoid it and still keep the behaviour of the section header not sticking around?

Edit:

The code I'm using (to be clear what is happening here)

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (section == contribsSectionNum)
    {
        return [[[NSBundle mainBundle] loadNibNamed:@"ContribDisplayHeader" owner:self options:nil] objectAtIndex:0];
    }
    else
    {
        return nil;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == contribsSectionNum)
    {
        return 43;
    }
    else
    {
        return 0.0;
    }
}

您是否尝试过实现UITableview的heightForHeaderview委托方法?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM