ios - [UIScreen mainScreen]iOS 7和iOS 8.bounds.size差异

标签 ios cocoa-touch ios7 ios8

iOS 8 中的 UIScreen 现在是面向界面的 ( Is [UIScreen mainScreen].bounds.size becoming orientation-dependent in iOS8? )。

我的应用仅在横向模式下运行 - 因此在 iOS 7 和 iOS 8 中,bounds.size.width 和bounds.size.height 的值将会切换。为了支持 iOS 7 和 iOS 8,这是否意味着在我的代码中,我需要检测 iOS 的版本(或者例如将两个尺寸中较大的一个分配给我的“宽度”变量,将较短的一个分配给“高度'变量)?我应该补充一点,我正在以编程方式创建 View 。

最佳答案

是的,您需要以编程方式检查操作系统版本并返回适当的值。这是一种检查方法:How can we programmatically detect which iOS version is device running on? .

关于ios - [UIScreen mainScreen]iOS 7和iOS 8.bounds.size差异,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25990631/

相关文章:

ios - 从 UITableView 中去掉左边的空间

ios - objective-c - IB - 垂直居中 3 多行 UILabels

ios - Facebook 登录无法快速工作

ios - UILocalNotification 后台事件触发以暂停 iOS 中的音乐

ios - iTunes 描述中的要点

iphone - UIImagePickerController 在模拟器上工作,在设备上崩溃

ios - UISlider 最小和最大轨道色调清除颜色 iOS 7.1 错误

ios - 如何防止人们选择器导航 Controller 自动解雇

ios - 无法设置 RightBarButtonItems 的位置

ios - 从 iOS 9 开始,应用程序 :openURL:sourceApplication:annotation: is deprecated, 如何在 iOS 8 中使用新方法?