Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
500 views
in Technique[技术] by (71.8m points)

iphone - Default height for section header in UITableView

I want to set the height of the first header in my UITableView. For the other headers I want them to remain the default height. What value/constant can I put in place of "someDefaultHeight" in the code below?

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

    return someDefaultHeight;
}

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In IOS 5.0 onwards you can return UITableViewAutomaticDimension in most of the delegate methods. Its at the bottom of the documentation page

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if(section == CUSTOM_SECTION)
    {
        return CUSTOM_VALUE;
    }
    return UITableViewAutomaticDimension;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...