0

在 iOS 8 之前的 iOS 版本中,要检查设备是否为 iPhone 5/iPhone 5s,检查 [UIScreen mainScreen].bounds.size.height == 568.0 就足够了。但在 iOS 8.x 及以后的版本中,此检查可能会失败,因为边界现在取决于方向。我需要一个解决方案来识别 iPhone 5s、6 和 6+ 设备,而无需检查 iOS 版本。

4

2 回答 2

1

你可以检查是否

[UIScreen mainScreen].bounds.size.height == 568.0   

[UIScreen mainScreen].scale识别 iPhone 6 和 6+

请注意,如果应用程序在“缩放”模式下工作,这将不起作用。
在这种情况下,iPhone 6 和 6+ 将提供 scale 2.0

于 2014-11-11T08:16:51.477 回答
0

我能够使用以下宏检测设备。如果您想识别设备,这将很有用,以对视图执行一些更新(例如在方向更改时更新框架)。如果您确实想要设备型号/品牌,请改用此链接(ios iphone get device model and make?)。

#define IS_IPHONE       ((int)(MAX([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)) == 480)
#define IS_IPHONE5      ((int)(MAX([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)) == 568)
#define IS_IPHONE6      ((int)(MAX([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)) == 667)
#define IS_IPHONE6PLUS  ((int)(MAX([UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height)) == 736)
于 2014-11-11T08:47:01.767 回答