ios - 获取有关当前模拟器设备的信息

标签 ios swift

据我所知,如果我想知道正在使用哪种类型的设备(iPod、iPhone 4、iPhone 5 等),我应该使用 (swift):

UIDevice.currentDevice().model

但此代码仅适用于真实设备,如果运行模拟器,它只会显示:iPhone 模拟器。没关系哪种类型。如何获取当前模拟器设备的信息?

最佳答案

检查屏幕大小以确定模拟器正在运行的设备:

let screenSize: CGRect = UIScreen.mainScreen().bounds
let screenWidth = screenSize.width;
let screenHeight = screenSize.height;

如果您想获取操作系统的版本等,您可以使用 UIDevice.currentDevice() 来访问其他详细信息:https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIDevice_Class/index.html#//apple_ref/occ/instp/UIDevice/systemName

关于ios - 获取有关当前模拟器设备的信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25067471/

相关文章:

ios - Core Audio 大型(压缩)文件播放和内存占用

ios - 从 swift ViewController 发送消息到 Objective C ViewController

ios - UIWebView addSubView UIButton 按钮点击事件没有响应

ios - 当父 View 将 alpha 设置为半透明时,如何强制 View 中的元素不透明

swift - '-[__NSCFDictionary setObject :forKey:]: mutating method sent to immutable object' cause crash

ios - 想要使用 swift 生成随机数学函数吗?

ios - SceneKit 中的土星环节点

ios - iPhone - 重用 TableViewCells

ios - 在 Swift 中的 tableviewcell 之间添加空间

ios - 如何在 Firebase DB 中更新子项的特定值