Search code examples
iosautolayoutstoryboardconstraintsnslayoutconstraint

iOS - vary for traits for landscape and portrait fails


So i am trying to locate a view inside my VC using auto layout. In the story board it looks great: In landscape the view in the middle of the view(x and y) enter image description here

In portrait it is in the middle of x but in the bottom of the view: enter image description here

Yet in the phone it is ok in the portrait: enter image description here

but in landscape it is wrong: enter image description here

The steps to build it used by me are as follow:

1.gave the view width and height

2.pressed vary for traits in portrait and add constraints

3.In landscape pushed vary for traits and gave the constraints i needed

thanks


Solution

  • Ok, So the problem wasn't in the constraints or the vary for trait but in the size of the device. We have deferents groups of sizes: 4.7,5.5,5.8,6.5 and ipads. I did the traits on the wrong group, once i changed it to the appropriate one it worked like a charm.