如何删除UITableView节之间的垂直间距?

如何删除UITableView节之间的垂直间距?,uitableview,Uitableview,我有一个包含几个部分的分组表视图。默认情况下,各部分之间存在间隙。我一直在寻找一个简单的方法来消除差距完全没有任何运气。通过Interface Builder,我能做的最好的事情就是在“Table View Size”属性部分中设置“Section Height”值,但是这些字段不接受0作为有效输入。有谁能告诉我解决这个问题的最佳方法吗?在表视图的委托中,您可以实现和 上面的答案对我来说不起作用,我必须实际创建一个高度为1、背景色为透明的UIView,然后将其y原点坐标设置为-1 - (UIVi

我有一个包含几个部分的分组表视图。默认情况下,各部分之间存在间隙。我一直在寻找一个简单的方法来消除差距完全没有任何运气。通过Interface Builder,我能做的最好的事情就是在“Table View Size”属性部分中设置“Section Height”值,但是这些字段不接受0作为有效输入。有谁能告诉我解决这个问题的最佳方法吗?

在表视图的委托中,您可以实现和


上面的答案对我来说不起作用,我必须实际创建一个高度为1、背景色为透明的UIView,然后将其y原点坐标设置为-1

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, -1, tableView.frame.size.width, 1)];
    [view setBackgroundColor:[UIColor clearColor]];
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 1;
}
这给了我一个分组的表视图,其中节单元格不会在headerView下面滚动,并且节之间没有填充

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, -1, tableView.frame.size.width, 1)];
    [view setBackgroundColor:[UIColor clearColor]];
    return view;
}

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