Fixing the PhoneGap / Cordova Splash Screen
I have a couple of PhoneGap / Cordova apps which have developed to the point where the little details matter. One of those little details is the annoying 20px jump when the standard iOS loading image is replaced with the Cordova splash screen which covers the web view while HTML is loaded.
I have written a patch that repositions the standard splash screen, but for more immediate use, the below code fixes the issue without requiring a custom build of the library.
Most of the code is copied from CDVViewController - showSplashScreen to override the base class version and a bunch of private methods that are called from showSplashScreen.
This is kept as close as possible to the base class version. A new view splashView takes the place of the imageView from the base class, which is read only. The real change is the adjustments to splashView.center - the image needs to be moved out from under the status bar, and it moves in a different direction for each orientation.
Note the use of
if (self.splashView != nil) return; at the start of the method. This is necessary because the base class checks for the presence of imageView, which is no longer used, and calls the method twice - without it you get two splash screens, only one of which can be hidden.
The standard splash screen with automatic hiding will not be used, so hiding the splash screen requires an extra step in AppDelegate:
hideSplashScreen is an optional custom method -
splashview.hidden=YES; would also work, but a fade looks nicer.