Sometimes when I open my app (either while resuming it after it was dormant for a while or while opening it after it has been \'quit\'), the splash screen, which basically j
The cause of the problem was that I was performing a long-ish operation upon applicationWillTerminate:, which delayed the 'true' termination of the app for a short bit (I assume). So, when I re-open the app right after closing it, this operation (writing data to disk) is still going on, so the app hasn't truly been quit. This is what I believe is the issue from what I can deduce.
Like Caleb says, your application is being suspended but not really exiting. To force your app to exit when it's suspended, set UIApplicationExitsOnSuspend
to YES
in your ProductName-Info.plist.
Are you certain that the app is really launching instead of just being suspended? The behavior your describe sounds exactly like that of an app that has been suspended and written out to secondary storage.
Device os create snapshot screen image when application goes in background, here is path you can find in sandbox of application "AppData/Library/Caches/Snapshots/".
Here is a trick that you can prevent to show last screen of app, when you launch application.
// Create subclass of UIImageView
@interface SnapShotImageView :UIImageView
@end
@implementation SnapShotImageView :UIImageView
@end
// Create function in appdelegate.m
- (void)createSnapshotWhileApplicationGoesInBackground{
NSString *splashImg = nil;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
splashImg= @"Default~ipad.png";
}
else {
splashImg= @"Default~iphone.png";
}
UIWindow *win = [[UIApplication sharedApplication] keyWindow];
SnapShotImageView *splash = [[SnapShotImageView alloc] initWithImage:[UIImage imageNamed:splashImg]];
splash.frame = self.window.bounds;
[win addSubview:splash];
}
- (void)removeSnapshotFromWindow{
UIWindow *win = [[UIApplication sharedApplication] keyWindow];
if ([[win subviews] count] > 1) {
[NSThread sleepForTimeInterval:0.5];
NSArray *array = [win subviews];
[array enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if ([obj isKindOfClass:[SnapShotImageView class]]) {
[obj removeFromSuperview];
}
}];
}
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[self removeSnapshotFromWindow];
}
//Call this function Application delegate method this way..
- (void)applicationDidEnterBackground:(UIApplication *)application {
[self createSnapshotWhileApplicationGoesInBackground];
}
- (void)applicationWillEnterForeground:(UIApplication *)application{
[self removeSnapshotFromWindow];
}
- (void)applicationDidBecomeActive:(UIApplication *)application{
[self removeSnapshotFromWindow];
}
here we creating snapshot of splash screen.. just adding splash screen in window. when application goes in background
and removeing snapshot when application comes in foreground
Yes, that's working as intended. Every time your app is going to suspended state, iOS will take a screenshot and use it as a launching image on next launch, except if it's a fresh launch. So "or while opening it after it has been 'quit'" doesn't seem right. If that really happens, it means your app was not quit when you think it was.
Anyway, it doesn't matter if app launches from scratch or from background, you should always display your view as soon as possible, give user some kind of notice that it's loading, then handle loading content asynchronously, not have the user wait for unresponsive app hoping it will work some time soon.