Why is the scale representing screen size wrong in iOS for my iPad Mini?

安稳与你 提交于 2019-12-07 12:20:57

问题


I have a 1st generation iPad Mini (Model A1432) with a screen resolution of 1024x768 (documentation).

I have the following code in my app:

CGRect screenBounds = [[UIScreen mainScreen] bounds];
CGFloat screenScale = [[UIScreen mainScreen] scale];
CGSize screenSize = CGSizeMake(screenBounds.size.width * screenScale, screenBounds.size.height * screenScale);

screenSize.height and screenSize.width report: 2048x1536, which is wrong. The screenScale value is 2, but it is my understanding that it should only be 2 for retina screens, which the 1st generation iPad Mini is not.

Any ideas why this might be happening? I'm trying to have code in my app that determines the screen resolution at runtime, as I am doing pixel manipulation for an augmented reality app.

Many thanks for any help.


回答1:


After a discussion in comments...!

If you run an iPhone only app on an iPad it will simulate a retina device and report a scale of 2.0. We know (from the above!) that the iPad mini (gen 1) does this as well as the standard iPad 2 running iOS 7 would too.

This was introduced in iOS 7.

Nice gotcha to watch out for!



来源:https://stackoverflow.com/questions/23328110/why-is-the-scale-representing-screen-size-wrong-in-ios-for-my-ipad-mini

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!