gpt4 book ai didi

ios - 在 UITableView 中隐藏节标题

转载 作者:行者123 更新时间:2023-11-29 03:06:21 27 4
gpt4 key购买 nike

我想在 UITableView 中隐藏第一部分的标题。因此,我在下面的函数中将高度设置为 0。但是标题仍然显示?怎么了?如果我将它设置为例如1 我看到 table 上有一条小线。有什么想法吗?

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

最佳答案

我通过在 viewDidLoad() 方法中添加以下代码行解决了这个问题。另外将 heightForHeaderInSection 中的高度设置为 1.0f(方法见上文)。

// Correct position because section header height will be set to 1 in order to hide it.
self.tableView.contentInset = UIEdgeInsetsMake(-1.0f, 0.0f, 0.0f, 0.0);

关于ios - 在 UITableView 中隐藏节标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22737251/

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