我已经为我的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.
更多推荐
发布评论