简体   繁体   English

UIViewController里面的UITableView意外边距

[英]UITableView inside UIViewControllerView unexpected margins

I have normal UIViewController on my storyboard with a standard UIView which contains only one child - UITableView 我的故事板上有一个普通的UIViewController ,标准的UIView只包含一个子UITableView

When adding constraints between UIView and UITableView ( equal widths, equla heights, vertical space 0 top layout guide, horizontal space 0 for leading margin ) as a result my table view should fill it's parent. UIViewUITableView之间添加约束时(相等的宽度,等高,垂直空间0顶部布局指南,前导边距的水平空间0)因此我的表视图应该填充它的父级。

Instead my table view appears to have left and top margins (16 and 64). 相反,我的表格视图似乎有左边距和上边距(16和64)。 The Size Inspector shows that the table views Alignment Rectangle is as follows x=16,y=64,width=600,height=600 although all my constraints have constants set to 0's. Size Inspector显示表格视图Alignment Rectangle如下x = 16,y = 64,width = 600,height = 600,尽管我的所有约束都将常量设置为0。 When I try to edit manually Alignment Rectangle I keep getting Misplaced Views warnig which try to restore previous values. 当我尝试手动编辑Alignment Rectangle我不断获取Misplaced Views warnig,它会尝试恢复以前的值。

Any I idea what might be the cause of this strange behaviour? 我知道这可能是造成这种奇怪行为的原因吗?

Click the view you want to remove margins. 单击要删除边距的视图。 Open Contraint Editor uncheck Prefer Margin relative : 打开Contraint Editor取消选中Prefer Margin relative

在此输入图像描述

I had a very similar problem. 我有一个非常相似的问题。 It was solved by deselecting Under Top Bars under Extend Edges in the properties of the topmost UIViewController in storyboard. 通过在故事板中最顶层的UIViewController的属性中取消选择Extend Edges Under Top Bars ,解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM