5

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.)

  • Are you creating a universal / iPad only app? – James Webster Jun 20 '12 at 09:57
  • 1
    Ok, I could have seen a possible issue if iPhone only. – James Webster Jun 20 '12 at 09:59
  • How are you doing the comparison that makes you think its returning 1.0? Also, do you have another screen connected (with the external adapter/AirPlay)? – Nick Forge Jun 20 '12 at 10:16
  • @NickForge: I'm using cocos2d which uses `if ([[UIScreen mainScreen] scale] == 1.0)` to early-out of its retina support setup. I have used a debugger to verify that, yes, `scale` is returning 1.0 and that is why the code is being skipped. I am not using an external screen. –  Jun 20 '12 at 10:19
  • Also the first line in `application:didFinishLaunchingWithOptions:`, before any other setup, gets the screen bounds (with `[[UIScreen mainScreen] bounds]`); they are 768x1024. –  Jun 20 '12 at 10:22
  • 1
    screen bounds should always be 768x1024 (that's the point of using 'points' and not pixels, and having a scale factor instead). You said 'to(o?) early-out'... does it still yield scale == 1.0 even long after initialization? – Nicolas Miari Jun 25 '12 at 13:32
  • @ranReloaded: How long is "long"? When should I be checking for presence of a Retina display? –  Jun 25 '12 at 13:44
  • I'm not sure, if it's a Cocos2D-specific API you're using (this, regarding the answer below). `[[UIScreen mainScreen] scale]` should return the correct value as early as `-applicationdidFinishLaunching[withOptions:]` – Nicolas Miari Jun 25 '12 at 14:01
  • Were you able to test in a 'supported' configuration of Mac OS X/Xcode? Does it still happen? – Nicolas Miari Jun 25 '12 at 14:02
  • I am not using any specific cocos2d APIs in testing this. I have not been able to test it in a supported configuration (and there's no way I'm upgrading to Lion at this date). –  Jun 25 '12 at 14:41

2 Answers2

4

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.

-3

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

George
  • 4,029
  • 1
  • 23
  • 31
  • "Also , don't forget to enable retina support." The whole problem is that cocos2d is _not_ enabling retina support, and it's not enabling it because it checks for a retina display using the screen scale. –  Jun 25 '12 at 13:27
  • @Noah Witherspoon - read the comments above - the user that asked the question says he uses cocos2D. – George Jun 28 '12 at 11:03