gpt4 book ai didi

ios - 嵌入在其他 View 中的 UITableView 的节标题位置错误

转载 作者:可可西里 更新时间:2023-11-01 03:35:58 28 4
gpt4 key购买 nike

我在另一个 View 中嵌入了一个 UITableView,如下所示:

storbyboard showing both parent and embedded view controller

导航 Controller 是模态显示的,所以它的布局应该是全屏的,不依赖于 Storyboard的任何其他部分。如果已经使用固定的自动布局约束设置了配置文件 View 的上部,如下所示:

  • ImageView 的顶部布局指南(灰色的):20pt
  • “交易”标签的 ImageView :20pt
  • 容器 View 的“交易”标签:20pt
  • 到底部布局指南、前导和尾随空间的容器 View 距离:均为 0pt。

所以基本上,当屏幕变大时,容器 View 应该填充剩余空间。

在容器 View 中,我嵌入了一个 TableView (包括相应的 Controller )。为了让问题更明显,我给容器 View 一个绿色背景,给表格 View 一个蓝色背景(这就是为什么部分标题略带蓝色)。当然,我希望 TableView 填满整个容器 View 。但这只是部分发生:

app screenshot showing that table view does fill the complete container view, but section header is positioned too low

因此 TableView 确实填满了整个容器 View ( TableView 的背景颜色为蓝色),但节标题位置较低。如果我向下滚动,部分标题会保持在同一位置,但单元格会向上移动并显示在其上方:

app screenshot after scrolling in table view

我已经尝试选中和取消选中 TableView Controller 的“扩展边缘”复选框,这些复选框控制它是否扩展“Under Top Bars”、“Under Bottom Bars”和“Under Opaque Bars”,但这没有帮助。看起来表格 View 为导航栏和状态栏留出了空间,但它不应该而且我不明白如何让它正确地布置节标题和单元格。

知道为什么会这样吗?我该如何解决?

最佳答案

这可以通过取消选中 IB 中包含容器 View 的 Controller 的“Under Top Bars”框来解决,而不是 TableView Controller 。您必须这样做似乎是不正确的,因为您会认为将主视图(在容器 Controller 中)扩展到导航栏下方不会使嵌入式 TableView 按照它的方式运行。

关于ios - 嵌入在其他 View 中的 UITableView 的节标题位置错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23430279/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com