【发布时间】:2014-08-05 15:53:54
【问题描述】:
在视图控制器中,我只有一个 UITableView。在 IB 中,我将页眉和页脚高度设为 1,并且还添加了以下代码,但在第一个单元格上方,它们有很多页眉空间。我想摆脱那个空间。甚至滚动条也从第一个单元格开始,而不是在顶部。
-(CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
CGFloat height = 0.0001;
return height;
}
-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
CGFloat height = 0.0001;
return height;
}
-(UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
// Create Empty View
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width,
[self tableView:self.visitorlistsTv heightForHeaderInSection:section]) ];
return view;
}
-(UIView *) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
// Create Empty View
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width,
[self tableView:self.visitorlistsTv heightForFooterInSection:section]) ];
return view;
}
使用上面的代码,页脚部分被隐藏了。但也无法隐藏标题。
查看解决方案的其他链接我还在视图中添加了 TableView,向 tableview 添加了约束,但标题部分仍然是他们的。
我哪里错了?如何摆脱它?
【问题讨论】:
-
为什么需要高度这么小的页眉和页脚?这看起来像一个非常糟糕的黑客。你想解决什么问题?
-
我读到返回 0 高度没有任何区别,因此我尝试返回这么小的标题。在第一个单元格上方的表格顶部,它们是空白空间,我想删除该空间。
标签: ios objective-c uitableview