如何调整分组表视图中各部分之间的间距?

发布于 2024-09-10 15:51:48 字数 240 浏览 1 评论 0原文

我有一个表格视图,长度基本上有四个部分,专为用户输入而设计。到目前为止我还没有使用页眉或页脚。

第 0 部分有 4 行。 第 1 部分有 2 行。 第 2 部分有 1 行。 第 3 部分有 1 行。

我想让第 2 部分和第 3 部分靠得更近一些,第 0 部分和第 1 部分靠得更近一些——基本上是配置单元格之间的空间。

我进行了广泛的搜索,但没有找到任何关于如何执行此操作的具体信息。建议?

先感谢您,

I have a tableview that is basically four sections in length, designed for user input. I am not using headers or footers as of now.

Section 0 has 4 rows.
Section 1 has 2 rows.
Section 2 has 1 row.
Section 3 has 1 row.

I want to have section 2 and 3 a little closer together and sections 0 and 1 a little closer together - basically configuring the space in between cells.

I have searched far and wide and have found nothing specific on how to do this. Suggestions?

Thank you in advance,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

用心笑 2024-09-17 15:51:48

在此处处理

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

更多信息:

UITableView 不尊重 heightForHeaderInSection/heightForFooterInSection?

Handle

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

More info here:

UITableView Not Respecting heightForHeaderInSection/heightForFooterInSection?

叶落知秋 2024-09-17 15:51:48

如果您的表格视图设置为“分组”而不是“普通”,则可以使用默认的不可见页脚作为填充。这样你就可以让你的标题看起来不错(并且在第一部分上方不会有巨大的间隙)

  func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
      if section == 0 || section == 2 {
        return 20
      } else {
        return 40
      }
  }

仅供参考,如果你返回 0 它会忽略它并使用默认金额。要完全隐藏页脚,请将其设置为 0.0001 或其他值

If your tableview is set to Grouped, and not Plain, you can use the default invisible footers as padding. This way you can leave your headers looking good (and not have a giant gap above the first section)

  func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
      if section == 0 || section == 2 {
        return 20
      } else {
        return 40
      }
  }

Just FYI, if you return 0 it will ignore it and go with the default amount. To completely hide the footer, set it to 0.0001 or something

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文