ios - iPad Pro 设备检测

标签 ios objective-c ipad

我正在尝试检测 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!

谢谢

编辑: 有些人建议使用 LunchScreen ,但是当我使用它时会发生这种情况(按比例缩小): enter image description here

最佳答案

特别感谢@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/

相关文章:

objective-c - 输出高频信号耳机

iphone - UIPickerView 的大小设置不正确

当手指在上面时 CSS 更改 div bg (ipad)

ios - 在 iPad 上处理旋转到横向模式

ios - secItemAdd 快速返回 -50 错误

ios - self.title 和导航栏在 iOS 7 中不起作用

ios - 在 Swift 中创建可重用 View 并添加完成处理程序

iphone - 在 iOS 中读取 PPT、xls 和 .doc 文件的 SDK

ios - Captuvo iPod 条码扫描器在 sleep 后显示不兼容的固件

ios - 如果未显示所有 NavigationLink,则 NavigationView 中 SwiftUI 的 NavigationLink `tag` 和 `selection` 将停止工作