简体   繁体   中英

Top space on device rotation

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:

肖像1

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:

人像2

Why and how to fix it?

Try to uncheck Adjust scrollview insets Of viewcontroller attribute

在此处输入图片说明

Source Of Image: Here

You might have set TopConstraint of your view With margin.

Uncheck box for Add to Margin.

在此处输入图片说明

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 cc 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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