设置约束后,在NavigationBar后的UITableView(UITableView behind NavigationBar after setting constraints)

编程入门 行业动态 更新时间:2024-10-13 12:18:36
设置约束后,在NavigationBar后的UITableView(UITableView behind NavigationBar after setting constraints)

我已经为我的ViewController添加了一个TableView。

我已经设置了这样的约束:

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

我在这里做错了什么? 为什么tableView在navigationControllerBar后面?

I've added a TableView to my ViewController.

I have set the constraints like this:

Yet when i run the project the top of the firstcell(like 40px) is behind the NavigationBar:

What am i doing wrong here? Why is the TableView behind the navigationControllerBar?

最满意答案

您没有考虑使用约束的导航栏。 将顶部约束设置为50。

由于“界面”构建器中的场景没有导航栏 - 约束不考虑它,并且y(顶部)在视图上设置为0,该视图没有导航栏。

将顶部约束设置为50或在视图中放置一个条形并将顶部约束设置为它。

You're not accounting for the navigation bar using the constraints. Set the top constraint to 50.

Since the scene in the Interface builder does not have a navigation bar - the constraints are not considering it and y (top) is set to 0 on the view, which does not have a navigation bar.

Either set the top constraint to 50 or put a bar in the view and set the top constraint to it.

更多推荐

本文发布于:2023-08-04 10:58:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1413926.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:UITableView   NavigationBar   constraints   setting

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!