Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Size class wCompact|hAny gets overridden by wCompact|hRegular

I am getting strange behavior with size classes in Xcode 6. I didn't managed to find whether it a bug or documentation misreading.

The thing is: I have to provide different layouts one for iPhone 3.5, 4, 4.7 inch and another for 5.5 inch device.

I've create simple example to demonstrate the bug: the label has 2 constraints - center X and Y within container. enter image description here

I've set Y alignment constraint's constant to 100 for wCompact|hAny and -100 for wCompact|hRegular. enter image description here

The ui looks good in interface builder but not in preview - the wCompact|hRegular parameters override wCompact|hAny.

enter image description hereenter image description hereenter image description hereenter image description here

I'm get confused by the information from the popup window that arises in IB when you want to change size of your vc.

enter image description hereenter image description here

So is there a way to specify constraints for small iPhones and have different ones for large 5.5 screen?

like image 988
Max Komarychev Avatar asked Nov 01 '22 15:11

Max Komarychev


1 Answers

It is the desired behaviour, you choose the Any Width | Any Height combination to make layout decisions that apply to all possible device sizes and orientations, but choose the Compact Width | Regular Height combination to specify layout changes that apply only to sizes resembling iPhone devices in portrait orientation.

So Compact Width | Any Height parameters will overwrite Any Width | Any Height parameters for iPhone devices in portrait and landscape orientation. Compact Width | Regular Height parameters will overwrite Compact Width | Any Height parameters for iPhone devices in portrait orientation. General rule is specific size class overwrite more general ones. In your case, if you rotate to landscape orientation, the label origin Y is above the center's origin Y with a distance of 100, which has not been overwritten.

like image 65
gabbler Avatar answered Nov 15 '22 07:11

gabbler