gpt4 book ai didi

ios - 设置约束后导航栏后面的 UITableView

转载 作者:行者123 更新时间:2023-12-01 17:50:35 26 4
gpt4 key购买 nike

我在 ViewController 中添加了一个 TableView。

我已经设置了这样的约束:
enter image description here

enter image description here

然而,当我运行项目时,第一个单元格的顶部(如 40px)位于 NavigationBar 后面:

enter image description here

我在这里做错了什么?为什么是navigationControllerBar后面的TableView?

最佳答案

不要只将约束设置为 50,这在很多层面上都是错误的。

约束 TableView 的 View Controller 的从上到上的布局指南。这也将为您处理旋转。在横向中,导航栏的高度可能较小,这也是原因。如果你将它设置为 50,它可能看起来很荒谬。

或者像你一样将表格 View 固定到 super View 的顶部并设置contentInset属性到条的高度(如果您想要半透明的导航栏并在滚动时查看导航栏下的单元格,这很有用)。您可以在代码或 Storyboard 中执行此操作:

enter image description here

关于ios - 设置约束后导航栏后面的 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32624236/

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