2012-05-14 69 views
3

我有几个部分的分组表格视图。默认情况下,各部分之间存在差距。我一直在寻找一种简单的方法来完全消除缺口,但没有任何运气。通过Interface Builder可以做的最好的方法是在“Table View Size”属性部分设置“Section Height”值,但这些字段不接受0作为有效输入。任何人都可以告诉我解决这个问题的最好方法吗?如何删除UITableView节之间的垂直间距?

回答

2

对我来说,以上回答没有工作,我不得不实际创建为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; 
} 

这给了我一个分组的tableView其中,部分细胞不会滚动headerView下方,不会有部之间的填充。