When I kill my iPhone app and relaunch it I have an image of the app\'s previous state instead of the launch image. How can I force iOS to always show the launch image?
ignoreSnapshotOnNextApplicationLaunch method will not be called if the app is not invoked during state restoration.
If your app is NOT supporting Multitasking feature, which the UIApplicationExitsOnSuspend key in its Info.plist is Set to YES. The suggested solution will not work.
For me, I used the code below:
applicationWillResignActive is used for the situation when the app is running, you double click the home button to call the multitasking tray. The splash screen will show on the application screen. It works perfectly.
applicationWillTerminate is not working every time because the function could be never called on some stages
- (void)applicationWillResignActive:(UIApplication *)application {
NSLog(@"Application Did Resign Active");
self.viewController.webView.hidden = YES;
NSString *splashImage;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
splashImage = @"Default-Portrait~ipad.png";
}
else {
splashImage = @"Default~iphone.png";
}
UIImageView *splash = [[UIImageView alloc]initWithFrame:[self.window frame]];
[splash setImage:[UIImage imageNamed:splashImage]];
[self.window addSubview:splash];
}
- (void)applicationWillTerminate:(UIApplication *)application {
NSLog(@"Application is Terminated");
self.viewController.webView.hidden = YES;
NSString *splashImage;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
splashImage = @"Default-Portrait~ipad.png";
}
else {
splashImage = @"Default~iphone.png";
}
UIImageView *splash = [[UIImageView alloc]initWithFrame:[self.window frame]];
[splash setImage:[UIImage imageNamed:splashImage]];
[self.window addSubview:splash];
}