如何从表视图中删除节页眉和页脚视图?

时间:2010-05-05 11:52:42

标签: iphone ipad uitableview

我正在使用带有单个部分的分组表视图(因为我想要圆角矩形的单元格)我想删除表视图部分页眉和页脚以保存该大小但其页眉和页脚被删除但是它保持相同的大小... ......怎么解决这个......?

3 个答案:

答案 0 :(得分:4)

您可以在IB中编辑部分页眉和页脚的大小。在表视图上打开Inspector,然后转到大小选项卡。将节标题/页脚高度设置为最小

答案 1 :(得分:1)

添加此代码,它会将页眉和页脚的大小调整为零高度:

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

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0;
}

答案 2 :(得分:0)

您还可以尝试在表视图上的Inspector中移动Insets,或者以编程方式执行。请注意,这取决于设备所在的iOS系统版本,因此iOS 6插件与iOS7插件不同。

以编程方式执行:

UIEdgeInsets inset = UIEdgeInsetsMake(-35, 0, 0, 0); //iOS7 insets to line up with the navigation bar

self.tableView.contentInset = inset;
self.tableView.scrollIndicatorInsets = inset; //This is to make sure the scroll indicators are also the same.
相关问题