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.
I've set Y alignment constraint's constant to 100
for wCompact|hAny
and -100
for wCompact|hRegular
.
The ui looks good in interface builder but not in preview - the wCompact|hRegular
parameters override wCompact|hAny
.
I'm get confused by the information from the popup window that arises in IB when you want to change size of your vc.
So is there a way to specify constraints for small iPhones and have different ones for large 5.5 screen?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With