据我所知,如果我想知道正在使用哪种类型的设备(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/