我有一个包含几个部分的分组 TableView 。默认情况下,各部分之间存在间隙。我一直在寻找一种简单的方法来完全消除差距而没有任何运气。我可以通过 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;
}
这给了我一个分组的 tableView,其中部分单元格不会在 headerView 下方滚动并且在部分之间没有填充。
关于uitableview - 如何删除 UITableView 部分之间的垂直间距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10588789/