Prevent Splash Screen from showing after returning from background

て烟熏妆下的殇ゞ 提交于 2019-12-18 04:01:37

问题



I've noticed something that happens in every app i develop. It's usually not a concern but in this specific app it would be great if i could "fix" it, if it's even a bug.

Steps to re-produce the issue:

  • Start app , splash screen shows for approx. 3 seconds and app starts.
  • Press home button, app goes to background.
  • Bring app back from background (double clicking home screen and chosing it), shows the splash for half a second or so, and then the app goes back up .

Is it possible to get rid of that splash screen popping up for half a second on the way back from background? Its really a problem for this specific app.


回答1:


I know that this question is marked an "answered" - but the reality is that the answer was not correct in my case and I want to share.

I initially came to the conclusion that the most accurate answer above was from QueyJoh - "this is something handled by iOS ... Short answer: it's out of your hands."

However after experimenting I managed to locate the issue as being entries in my info.plist file controlling the status bar. Specifically I had entries for "UIStatusBarHidden" and "UIStatusBarStyle".

Removing these entries from my plist file immediately stopped my app from showing the Splash screen when switching away from my app and back again.

Problem solved.

Matthew




回答2:


Well, apparently this question wasn't very clever to begin with :) This "problem" only happens in the Simulator. When Debugging on the device itself, it works as expected.

No harm done. Thanks everyone who tried to help! :)




回答3:


In my experience, this is something handled by iOS (I'm going with experience because I've not seen any documentation about this). If the OS can restore the application state nice and quickly, it'll display a screenshot of its previous state while that state is restored.

However, if something will delay the process, such as the app not being in the background properly yet (such as during rapid task switching), or if something else predictable will delay the startup, then it reverts to the splash screen (instead of the screenshot), to ease the user experience.

Short answer: it's out of your hands.




回答4:


I have this problem too,now I had solve it.The reason is you did too many things in applicationDidEnterBackground ,try to decrease .




回答5:


Your code to display your splash screen should be in your appdelegate in the didFinishLaunchingWithOptions method. If it is then it only appears when your app actually starts up, not when it returns from the background.

Use something like this (I know it uses the old animation code but I 'm sure you can update it to blocks if you need to)...

    splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 20, 320, 460)];
    splashView.image = [UIImage imageNamed:@"Default.png"];

    [myWindow addSubview:splashView];
    [myWindow bringSubviewToFront:splashView];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationDelegate:self]; 
    [UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];
    splashView.alpha = 0.0;
    [UIView commitAnimations];

and then create a method called startupAnimationDone...

- (void)startupAnimationDone:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {

    [splashView removeFromSuperview];

    [splashView release];
}


来源:https://stackoverflow.com/questions/8143151/prevent-splash-screen-from-showing-after-returning-from-background

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!