UITableView中节标题的默认高度 [英] Default height for section header in UITableView

查看:116
本文介绍了UITableView中节标题的默认高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在UITableView中设置第一个标题的高度。对于其他标题,我希望它们保持默认高度。我可以在下面的代码中代替someDefaultHeight使用什么值/常量?

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

谢谢

推荐答案

在IOS 5.0以后,您可以在大多数委托方法中返回UITableViewAutomaticDimension。它位于文档页面的底部

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

这篇关于UITableView中节标题的默认高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆