iPhone 5 splashscreen not displaying correctly - Phonegap
I've received two answers elsewhere but haven't had time to test them out yet:From user T123 in the Phonegap Google Group:open CDVViewController.m -- find - (void) showSplashScreen
change about line: 690
From :
else // not iPad{ orientedLaunchImageFile = launchImageFile;}
To:
else // not iPad{ orientedLaunchImageFile = launchImageFile; /* Edited for 4-inch IP5 */ if(screenBounds.size.height == 568) orientedLaunchImageFile = [NSString stringWithFormat:@"%@-568h", launchImageFile];}
And from Brion who commented above, the following pull request, hoepfully to be incorporated into Cordova 2.2.0: https://github.com/apache/incubator-cordova-ios/pull/50
EDIT: Tried T123's solution and it's working for me!EDIT2: Brion's fix was incorporated in Cordova 2.2.0 which has now been released!
EDIT3: Just updating to highlight a comment for those who don't bother reading them:
For Phonegap version 1.4.1, I managed to get Hessius's fix to work like this: I copied the methods showSplashScreen, isIPad, resolveImageResource and the definition #define degreesToRadian(x) (M_PI * (x) / 180.0) from the file PGViewController.m to my MainViewController.m file. After that, XCode complained that I was assigning values to read-only attributes, so I edited the header file in PhoneGap.framework to make those two attributes readwrite. I also changed launchImageFilefrom Hessius's code to @"Default". This did the trick for me. – Joe Dyndale Oct 8 '12 at 15:23
The fix for this (https://issues.apache.org/jira/browse/CB-1482) is not out until 2.2. It is very risky to use the unstable version and I don't bother to compile from source code myself, so I tried the following hack:
In MainViewController.m
- (void) showSplashScreen { CGRect screenBounds = [[UIScreen mainScreen] bounds]; // HACK: PhoneGap pre-2.2 does not support iphone5 splash image well, so we just skip it if (screenBounds.size.height == 568) { return; } [super showSplashScreen]; }
This will disable showSplashScreen for iPhone5 to avoid the shorter launch image added by PhoneGap (iOS initial launch image is showing up fine). It worked for me and I barely notice any difference by hacking off showSplashScreen for iPhone5.
White Flicker
I was having this same problem with Cordova 2.2. I think it is worth mentioning that I had to take an added step in order to get the splash screen to render correctly.
I made the changes that were included in @Hessius answer. But I noticed that a white screen flash was produced after the splash screen appeared.
In the (void)showSplashScreen method others may see
if (launchImageFile == nil) { // fallback if no launch image was specified // if (CDV_IsIPhone5()) { // // iPhone 5 or iPod Touch 6th-gen // launchImageFile = @"Default-568h"; // } else { launchImageFile = @"Default"; // }}
Commenting the code out(or removing) that I have commented, eliminated the white flicker I was seeing in between app load and launch screen.
Hope this helps someone!