Top space on device rotation

荒凉一梦 提交于 2019-12-24 07:59:37

问题


I have the following constraints on my UIView in portrait mode:

And landscape:

This is screenshot of the ViewController when I open it first time:

Top space is OK.

Then I'm rotating the device to landscape:

Do you see that white space on the top?

And when I'm rotating it back to landscape, the space still stays:

Why and how to fix it?


回答1:


Try to uncheck Adjust scrollview insets Of viewcontroller attribute

Source Of Image: Here




回答2:


You might have set TopConstraint of your view With margin.

Uncheck box for Add to Margin.




回答3:


Considering black view about the imageview which contains Back button is a UIView (says, viewNav)

Constraints for viewNav:

if you'r changing the height of viewNav of rotation then use size classes as see below and click on landscape option. Now select your navView and click on height constraint and give c-c constraint like this

Constraints for UiImageView:

If you'r image covers the complete screen the give bottom constraint as 0.

This fixes every thing.

If you are using native navigationBar then you there will be no viewNav and now constraint for image will be

On giving top constraint, don't forget to select use standard value for top constraint then enter 64. Bottom and height is according to your need whatever you prefer.



来源:https://stackoverflow.com/questions/41184084/top-space-on-device-rotation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!