如何在模拟器中检测iPad pro 运行?

How to detect the iPad pro running in the simulator?

我发现了很多关于设备检测和屏幕尺寸的帖子。 但是 none 这些可以与模拟器一起使用。

模拟器设备类型正常returnsx86_64.

和屏幕尺寸[UIScreen mainScreen].bounds.size.heightreturns1024.

我有一个场景需要调整尺寸 类 不适合的绘图代码。

我被难住了。

尽管我认为您不应该手动执行此操作,但这里有一些选项。

首先,您可以将边界乘以比例:

CGSize size = [UIScreen mainScreen].bounds.size;
CGFloat scale = [UIScreen mainScreen].scale;
CGSize realSize = CGSizeMake(size.width * scale, size.height * scale);

或者从 iOS 8 开始,您实际上可以更轻松地做到这一点:

CGSize realSize2 = [UIScreen mainScreen].nativeBounds.size;

并且根据 documentation 第二种方法忽略方向,因此可能更容易检查。

希望这对您有所帮助。