我可以检测到该应用程序正在 iOS 模拟器 下运行(使用 sysctlbyname("hw.machine")
),但我如何知道它是 iPad 还是 iPhone模拟器?
当然我可能会检查[UIScreen mainScreen].bounds
,但可能有更优雅的方式?
最佳答案
苹果手机:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { }
iPad:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { }
关于iphone - 检测应用程序是否在 iPad 模拟器中运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11097362/