uitableview - 如何删除 UITableView 部分之间的垂直间距?

标签 uitableview

我有一个包含几个部分的分组 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/

相关文章:

ios - 如何在 UITableViewCell 中创建未知数量的 UILabels?

iphone - UITableview titleForHeaderInSection 显示不正确

uitableview - 将 UITableViewDataSource 放入泛型类时出现 NSInvalidArgumentException

objective-c - tableview 上的 setediting = true 使单元格附件 View 消失?

swift - 自定义 Accordion /可折叠 UITableViewCell 的自动布局

iphone - UITableView 在 UITableViewCell 中?最好的设计是什么?

ios - 在 iOS 中根据数组中的值自动更新 UiLabels

ios - 重写 Swift 中行插入的 withRowAnimation 样式

ios - UITableViewCell - 每个部分勾选一行

ios - tableview cell 我们如何快速调整单元格的大小以及图像和标签