WCompact Size Class | hAny canceled by wCompact | hRegular

I get weird behavior with size classes in Xcode 6. I could not find if this is a bug or a misunderstanding of the documentation.

The fact is that I have to provide different layouts for the iPhone 3.5, 4, 4.7 inches and another one for the 5.5-inch device.

I am creating a simple example to demonstrate an error: a label has 2 restrictions - the center of X and Y in the container. enter image description here

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

ui looks great in the interface builder, but not in the preview - wCompact|hRegular overrides wCompact|hAny .

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

I am confused by the information from the popup that appears in IB when you want to resize your vc.

enter image description hereenter image description here

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

+5
source share
1 answer

This is the desired behavior, you choose any width | Any combination of heights for making layout decisions that apply to all possible device sizes and orientations, but choose Compact Width | A regular height combination to indicate layout changes that apply only to dimensions resembling iPhone devices in portrait orientation.

Parameters Compact Width | Any Height Compact Width | Any Height will overwrite Any Width | Any Height Any Width | Any Height for portrait and landscape iPhone devices. Parameters Compact Width | Regular Height Compact Width | Regular Height will overwrite Compact Width | Any Height Compact Width | Any Height for iPhone devices in portrait orientation. A general rule is a class of a certain size that overwrites the more general ones. In your case, if you rotate to landscape orientation, the beginning of the label Y is above the center beginning Y with a distance of 100 that has not been overwritten.

+2
source

Source: https://habr.com/ru/post/1205008/


All Articles