gpt4 book ai didi

ios - 如何更改分组的 UITableView header 的高度?

转载 作者:IT王子 更新时间:2023-10-29 07:31:05 25 4
gpt4 key购买 nike

我知道如何更改 TableView 中节标题的高度。但是我找不到任何解决方案来更改第一部分之前的默认间距。

现在我有这段代码:

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

enter image description here

最佳答案

返回CGFLOAT_MIN,而不是您想要的部分高度的 0。

Returning 0 causes UITableView to use a default value. This is undocumented behavior. If you return a very small number, you effectively get a zero-height header.

swift 3:

 func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if section == 0 {
return CGFloat.leastNormalMagnitude
}
return tableView.sectionHeaderHeight
}

swift :

func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if section == 0 {
return CGFloat.min
}
return tableView.sectionHeaderHeight
}

objective-C :

    - (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (section == 0)
return CGFLOAT_MIN;
return tableView.sectionHeaderHeight;
}

关于ios - 如何更改分组的 UITableView header 的高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17699831/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com