iOS App Launch Image After a Kill

前端 未结 5 2186
-上瘾入骨i
-上瘾入骨i 2021-02-09 06:16

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?

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-09 06:32

    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];
    
    }
    

提交回复
热议问题