我正在尝试检测 iPad Pro 设备,并尝试通过以下方式猜测其高度:
NSLog(@"%f",self.view.frame.size.height);
但它返回 1024
!与 iPad 非视网膜设备相同。有什么建议吗?
我需要用这行代码为 iPad Pro 指定一些代码:
#define iPadPro ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && [UIScreen mainScreen].bounds.size.height == 2732)
...即使在 iOS 模拟器上,代码也必须检测到 iPad Pro!
谢谢
最佳答案
特别感谢@rmaddy
检测屏幕尺寸的正确方法是:
NSLog(@"%f",[UIScreen mainScreen].bounds.size.height);
现在,如果您的应用程序以Portrait
模式运行,您可以简单地使用此代码来检测 iPad Pro:
#define iPadPro ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad && [UIScreen mainScreen].bounds.size.height == 1366)
Don't forget the need to use a LaunchScreen or the app won't take advantage of the iPad Pro's larger screen
关于ios - iPad Pro 设备检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33453340/