From 2f37eed1840619c31f5fdc746cbf9324ef6afb53 Mon Sep 17 00:00:00 2001 From: Nic Mulvaney Date: Sat, 11 Oct 2014 18:53:40 +0100 Subject: [PATCH] Fix for portrait/landscape detection Sometimes the width can be 568 or 320 depending on orientation on iPhone 5. This fixes the detection. Signed-off-by: Shazron Abdullah --- src/ios/CDVSplashScreen.m | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ios/CDVSplashScreen.m b/src/ios/CDVSplashScreen.m index ade5df0..4b4d466 100644 --- a/src/ios/CDVSplashScreen.m +++ b/src/ios/CDVSplashScreen.m @@ -124,16 +124,19 @@ UIScreen* mainScreen = [UIScreen mainScreen]; CGFloat mainScreenHeight = mainScreen.bounds.size.height; + CGFloat mainScreenWidth = mainScreen.bounds.size.width; + + int limit = MAX(mainScreenHeight,mainScreenWidth); device.iPad = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad); device.iPhone = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone); device.retina = ([mainScreen scale] == 2.0); - device.iPhone5 = (device.iPhone && mainScreenHeight == 568.0); + device.iPhone5 = (device.iPhone && limit == 568.0); // note these below is not a true device detect, for example if you are on an // iPhone 6/6+ but the app is scaled it will prob set iPhone5 as true, but // this is appropriate for detecting the runtime screen environment - device.iPhone6 = (device.iPhone && mainScreenHeight == 667.0); - device.iPhone6Plus = (device.iPhone && mainScreenHeight == 736.0); + device.iPhone6 = (device.iPhone && limit == 667.0); + device.iPhone6Plus = (device.iPhone && limit == 736.0); return device; }