Why is [[UIScale mainScreen] scale] 1 on an iPad 3 with Xcode 4.2?

别来无恙 提交于 2019-12-06 04:04:13

问题


When testing on my iPad 3,

[[UIScreen mainScreen] scale] == 1.0

My understanding is that this should be 2.0.

I am using the iOS 5.1 SDK with Xcode 4.2 on Snow Leopard, which I understand is not an "officially supported" configuration. However, I can't imagine why that would affect what is happening purely on the device. (I can imagine all sorts of ways it would break the simulator.)


回答1:


Before XCode version 4.3, [UIScreen scale] will return 1.0 for an iPad 3. Updating to 4.3 will enable the correct value of 2.0 being returned.




回答2:


That's because the screen is not scaled. You can get the ratio like this:

[[CCDirector sharedDirector] winSize].width/[[CCDirector sharedDirector] winSizeInPixels].width

If this is equal to 1 then you are on a non-retina device. Otherwise , if 2 , on a retina display. Also , don't forget to enable retina support.

Regards,

George



来源:https://stackoverflow.com/questions/11117041/why-is-uiscale-mainscreen-scale-1-on-an-ipad-3-with-xcode-4-2

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