[英]Detect if app is running in iPad simulator
I can detect that app is running under iOS Simulator (using sysctlbyname("hw.machine")
), but how do I know if it is iPad of iPhone simulator? 我可以检测到该应用程序正在iOS模拟器下运行(使用
sysctlbyname("hw.machine")
),但是如何知道它是否为iPhone模拟器的iPad?
Of course I may check [UIScreen mainScreen].bounds
, but probably there are more elegant way? 当然,我可以检查
[UIScreen mainScreen].bounds
,但是可能还有更优雅的方法?
iPhone: 苹果手机:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { }
iPad: iPad的:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { }
糟糕,刚刚发现[[UIDevice currentDevice] model]
了我的需求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.