0

For some reason this won't work since I updated to the latest xcode with iOS 8. it doesn´t recognize ([[UIScreen mainScreen] scale] == 2.0) &

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

// Indicates game is running on iPad
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    CCLOG(@"Running on iPad");
    // it doesn´t recognize this any more
    if ([[UIScreen mainScreen] scale] == 2.0) {
        CCLOG(@"Running on iPad Retina");
    } else {
        CCLOG(@"Running on iPad 2");
    }      
} else {
    CCLOG(@"Running on iPhone");
    // it doesn´t recognize this any more
    if ([[UIScreen mainScreen] bounds].size.height == 568.0) {
        CCLOG(@"Running on iPhone 5");
    } else {
        CCLOG(@"Running on iPhone 4/4S");
    }
}
Waqas Raja
  • 10,802
  • 4
  • 33
  • 38
Chris79
  • 33
  • 7
  • which devices did you used? did you tried this `[[UIScreen mainScreen] scale] == 2.0` on iPad Retina? – Waqas Raja Sep 29 '14 at 05:32
  • Don't compare floating point numbers without an epsilon ;). Dunno if this is the error here but you should never do that. – HAS Sep 29 '14 at 05:39
  • @WaqasRaja I tried all simulators... ipad 2, ipad air, ipad retina, iphone 4s, iphone 5, iphone 5s, iphone 6, iphone 6 plus. when running on ipad, they all go the ipad 2 part when running on iphone, they all go to the iphone 4/4s part. – Chris79 Sep 29 '14 at 14:14
  • UPDATE: for some reason it started to work now for the ipad retina simulator... but still not for the iphone 5/iphone5s/iphone6/iphone6plus – Chris79 Sep 30 '14 at 04:40
  • bounds.height it's a float number, you can try to transform it in an Integer before to compare it: NSInteger screenHeight_Int=screenHeight; and compare this number if (screenHeight_Int==568)... etc – TonyMkenu Oct 14 '14 at 09:09

1 Answers1

0

You need to add the support for the iPhone 5. For this purpose you need to add a launch image named as Default-568h@2x.png to your project. Without this image iOS runs the app in compatibility mode i.e. height = 468

This issue is asked earlier in other questions

how-to-add-iphone-5-large-screen-support-to-ios-apps-in-xcode

How to develop or migrate apps for iPhone 5 screen resolution?

Community
  • 1
  • 1
Waqas Raja
  • 10,802
  • 4
  • 33
  • 38
  • I know that. I´m already using a launch image named Default-568h@2x.png. I have been using that since iOS 6... what I mean is, everything was working fine until I updated from Xcode 5 to Xcode 6. then the problems started – Chris79 Sep 30 '14 at 19:20
  • Update: I just tried my code on Xcode 5.1 and [[UIScreen mainScreen] bounds].size.height == 568.0 was working perfectly. What in Xcode 6 is causing this issue and how do I solve it? – Chris79 Oct 01 '14 at 04:41