Shibasis Sengupta
Shibasis Sengupta

Reputation: 649

Xcode Auto layout not working on all devices

I have setup auto layout constraints to have an image position properly on (lower end of the screen) multiple devices. Please see the settings here -

enter image description here

but I think the top section of the settings is messing up the image in few devices -

enter image description here

How can I force the x,y, height and width to be responsive on different screens and just follow the constraints mentioned?

Upvotes: 0

Views: 266

Answers (1)

Nullable
Nullable

Reputation: 994

If you can provide more complete layout information (including adjacent views) it is best.

From the layout information you provided, the constraints are incorrect.

1.Trailling and Leading can determine the horizontal latitude of the view, Center X is repeated

  1. Bottom and Align Bottom are duplicates, retaining one

  2. Vertical latitude determination also requires a Top constraint

  3. After setting the constraints, don't set the x, y shown in your screenshot, it will upset your existing constraints, there will be a yellow prompt for you to update the constraints.

Each view only needs horizontal and vertical constraints, the extra constraints will not be effective, and a warning will be prompted.

For UILabel, UIImageView, you don't need to set the width and height, depending on the content, there will be a default width and height.

Upvotes: 1

Related Questions