设备轮换时的顶层空间

时间:2016-12-16 12:08:40

标签: ios xcode autolayout interface-builder ios-autolayout

我在纵向模式下对我的UIView有以下限制:

Portrait

景观:

Landscape

这是我第一次打开它时ViewController的屏幕截图:

Portrait 1

顶部空间还可以。

然后我将设备旋转到横向:

Landscape

你看到顶部有空白区吗?

当我将它旋转回景观时,空间仍然存在:

Portrait 2

为什么以及如何解决它?

3 个答案:

答案 0 :(得分:2)

尝试取消选中Adjust scrollview insets viewcontroller属性

enter image description here

图片来源:Here

答案 1 :(得分:1)

您可能已将视图的TopConstraint设置为保证金。

取消选中“添加到保证金”框。

enter image description here

答案 2 :(得分:1)

考虑包含Back按钮的imageview的黑色视图是UIView(说,viewNav)

viewNav的约束:

enter image description here

如果你改变了viewNav of rotation的高度,那么使用size size,如下所示,然后点击landscape选项。现在选择您的navView并单击高度约束并像这样给出c-c约束

enter image description here enter image description here

UiImageView的约束:

enter image description here

如果您的图像覆盖整个屏幕,则将底部约束设为0。

这解决了所有问题。

如果你使用的是native navigationBar,那么你将没有viewNav,现在对图像的约束将是

enter image description here

在给出顶部约束时,不要忘记选择use standard value作为顶部约束,然后输入64.底部和高度根据您的需要随意选择。