xcode iOS 7 中的大小类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26707300/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:04:59  来源:igfitidea点击:

Size Classes in iOS 7

iphonexcodesize-classes

提问by Kurt Anderson

I created a new app in Xcode 6 using Size Classes. After testing with iOS 7, I can't figure out how to get iPhone to display a certain size class while in landscape mode.

我使用大小类在 Xcode 6 中创建了一个新应用程序。在使用 iOS 7 进行测试后,我无法弄清楚如何让 iPhone 在横向模式下显示特定尺寸等级。

I first developed the UI with iPhone landscape as wAny hCompact, but iOS 7 doesn't recognize that. I had iPhone portrait in wAny hAny.

我首先将 iPhone 景观的 UI 开发为 wAny hCompact,但 iOS 7 不承认这一点。我在 wAny hAny 中有 iPhone 肖像。

I then changed it so now I'm using wCompact hRegular for iPhone portrait. I then modified wAny hAny to be the landscape layout. But it's not using that layout when the iOS 7 device is in landscape.

然后我改变了它,所以现在我将 wCompact hRegular 用于 iPhone 肖像。然后我将 wAny hAny 修改为横向布局。但是当 iOS 7 设备处于横向时,它不会使用该布局。

Is iOS 7 able to use different size classes based on the device being portrait or landscape? If so, which size class should I be using?

iOS 7 是否能够根据设备是纵向还是横向使用不同的尺寸类?如果是这样,我应该使用哪个尺寸等级?

Reference: Really helpful information about backwards compatibility with size classes.

参考: 关于与大小类的向后兼容性的真正有用的信息。

ps. I'm not concerned with iPad because the device does not display a different size class based on the device rotation in iOS 8.

附:我不关心 iPad,因为该设备不会根据 iOS 8 中的设备旋转显示不同的尺寸类别。

回答by Andrei Konstantinov

Size classes works in iOS 7 for sure. But only if you follow several rules:

大小类肯定适用于 iOS 7。但前提是您遵循以下几条规则:

  • The app is built using Xcode version 6or later
  • The deployment target of the app is earlier than iOS 8
  • Size classes are specified in a storyboard or xib file
  • The value of the height component is not compact (yep, this is your case, it's not possible in iOS 7, unfortunatelly)
  • 该应用程序是使用 Xcode 6或更高版本构建的
  • 应用的部署目标早于iOS 8
  • 大小类在故事板或 xib 文件中指定
  • 高度组件的值不紧凑(是的,这是您的情况,不幸的是,在 iOS 7 中这是不可能的

There is a little explanation here: https://stackoverflow.com/a/24976792/2190175

这里有一点解释:https: //stackoverflow.com/a/24976792/2190175

回答by Joseph Lord

No I'm afraid that Size Classes were introduced in iOS 8. You could write some conditional code to run on iOS to determine the screen/view size/orientation and change the the layout that way when iOS 8 becomes your minimum target the conditional code can be removed.

不,我担心尺寸类是在 iOS 8 中引入的。您可以编写一些条件代码在 iOS 上运行以确定屏幕/视图大小/方向,并在 iOS 8 成为您的最小目标条件代码时以这种方式更改布局可以删除。