Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show splash screen each time app becomes active

I want the splash screen to be displayed each time app becomes active. I have created a function showSplash which I call in applicationDidBecomeActive:

-(void)showSplash
{
    UIImageView *splashScreen = [[UIImageView alloc] initWithImage:[UIImage imageNamed: @"Default.png"]];
    [self.window.rootViewController.view addSubview: splashScreen];
    [self.window makeKeyAndVisible];
    NSLog(@"begin splash");
    [UIView animateWithDuration: 4.2
                          delay: 0.5
                        options: UIViewAnimationOptionCurveEaseOut
                     animations: ^{  
                         splashScreen.alpha = 0.0;
                     }
                     completion: ^ (BOOL finished) {
                         [splashScreen removeFromSuperview];
                         NSLog(@"end splash");
                     }
     ];
}  

This is how I call this function :

- (void)applicationDidBecomeActive:(UIApplication *)application {
[self showSplash];
}

But no splash screen appears. Please correct me.

like image 392
Nitish Avatar asked May 05 '15 17:05

Nitish


People also ask

How do I show splash screen only once?

It is important to check that the first activity which opens when the app is launched is MainActivity. java (The activity which we want to appear only once). For this, open the AndroidManifest. xml file and ensure that we have the intent-filter tag inside the activity tag that should appear just once.

How do I set splash screen time?

you can use Sleep method like this in your Splash Activity onCreate method: Thread timer1 = new Thread(){ @Override public void run(){ try{ sleep(4000); } catch (InterruptedException e){ e. printStackTrace(); } finally{ Intent intent = new Intent(SplashActivity. this, NextActivity.

What does splash screen on startup mean?

The splash screen is an introduction page that is displayed as a program or computer is loading or booting. For example, when a Microsoft Windows computer is starting up, there is a Windows splash screen that is displayed while Windows is loading.


1 Answers

If you want the application to have a fresh start every time you get back to it, you could also disable background execution, as stated in the Apple Documentation (last section titled "Opting Out of Background Execution"):

If you do not want your app to run in the background at all, you can explicitly opt out of background by adding the UIApplicationExitsOnSuspend key (with the value YES) to your app’s Info.plist file.

like image 150
Rufel Avatar answered Sep 19 '22 15:09

Rufel