大小类wCompact | hAny被wCompact | hRegular覆盖

时间:2014-10-19 11:38:19

标签: ios ios8 autolayout size-classes

我在Xcode 6中使用大小类获得了奇怪的行为。我没有设法找到它是错误还是文档误读。

问题是:我必须为iPhone 3.5,4,4.7英寸和5.5英寸设备提供不同的布局。

我创建了一个简单的示例来演示错误:标签有2个约束 - 容器中的中心X和Y. enter image description here

我已将100的Y对齐约束常量设置为wCompact|hAny-100设置为wCompact|hRegularenter image description here

ui在界面构建器中看起来不错,但在预览中看不到 - wCompact|hRegular参数覆盖wCompact|hAny

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

当您想要更改vc的大小时,我对IB中出现的弹出窗口中的信息感到困惑。

enter image description here enter image description here

那么有没有办法为小型iPhone指定约束,并为大型5.5屏幕设置不同的?

1 个答案:

答案 0 :(得分:2)

这是所需的行为,您选择任意宽度|任何高度组合,用于做出适用于所有可能的设备尺寸和方向的布局决策,但选择紧凑宽度|常规高度组合,用于指定仅适用于纵向类似iPhone设备的尺寸的布局更改。

因此,Compact Width | Any Height参数将以纵向和横向方式覆盖iPhone设备的Any Width | Any Height参数。 Compact Width | Regular Height参数将以纵向方式覆盖iPhone设备的Compact Width | Any Height参数。一般规则是特定大小类覆盖更一般的大小。在您的情况下,如果您旋转到横向,标签原点Y位于中心原点Y上方,距离为100,尚未覆盖。

相关问题