【问题标题】:Increasing space between Table View header and cell on storyboared增加故事板中表格视图标题和单元格之间的空间
【发布时间】:2023-04-10 10:37:02
【问题描述】:

我正在将我的应用程序迁移到 iOS 7,我注意到表格视图标题和单元格之间的空间很小。

  • 我认为这是 iOS 7 的正常行为?对。
  • 我以前看起来好多了,是否可以在使用故事板设计的静态 UITableView 中增加空间。

【问题讨论】:

  • 您可以添加截图以更清楚地了解您在说什么吗?

标签: ios uitableview ios7


【解决方案1】:

我认为这是 iOS 7 的正常行为?对。

是的这是正常行为。

是否可以在使用设计的静态 UITableView 中增加空间 故事板?

在 StoryBoard 中选择 tableview,然后更改 Attributes Inspector 下的值。

【讨论】:

    【解决方案2】:

    对于所有没有发现@Virus 答案有用的人,如果您有部分的动态标题高度,请遵循此方法

    //This method returns the height of a header at a specific section
    -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    {
        //For example you define heights for these sections
        switch (section)
        {
            case 0:
                return 12.0f;
                break;
    
            case 1:
                return 23.0f;
                break;
    
            case 2:
                return 56.0f;
                break;
    
            case 3:
                return 33.0f;
                break;
    
    
            default:
                return 25.0f;
                break;
        }
    }
    

    希望对你有帮助

    【讨论】: