Making the launch image display longer xcode

21,320

Solution 1

You can also do it by appliying following code in

 -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:  (NSDictionary *)launchOptions
 {
       [NSThread sleepForTimeInterval:2.0]; // Used For Showing Splash Screen for More Time
 }

First create the viewcontroller set the image what you want to show as splash screen/Launc image..

Present that view in method applicationDidFinishLaunching: with Animated:No

and write following code in your another view that your presenting

-(void) viewWillAppear:(BOOL)animated
{

        [self performSelector:@selector(dismiss1) withObject:nil afterDelay:5.0f];
        [super viewWillAppear:animated];

}



-(void) dismiss1
{

         [self dismissModalViewControllerAnimated:NO];

}

If you want to show the splash screen every time app opens, then present the splashscreen viewcontroller in applicationDidBecomeActive method

Solution 2

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

  /*this will pause main thread for x interval seconds. 
  put on the top of application:didFinishLaunchingWithOptions, so it will not 
  proceed to show window until sleep interval is finished.*/

    [NSThread sleepForTimeInterval:2]; //add 2 seconds longer.
   //other code....
}

Solution 3

You can use the sleep() method.

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    sleep(10);
    return YES;
}

Solution 4

Launch images are there to make your app appear really responsive and should be a snapshot of your UI prior to any items on it like tabBars, etc. Apple doesn't really want you to use them as splash screens.

That said, a lot of people do and to achieve this result, your App delegate needs to put the same image on screen as you launch image and then you can delay launching your main app with performSelector:withObject:afterDelay:

Solution 5

In Swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        Thread.sleep(forTimeInterval: 2.0)
        return true
}
Share:
21,320
Matan
Author by

Matan

Updated on August 29, 2020

Comments

  • Matan
    Matan over 3 years

    I need help with launch images on iphone. In the project settings on xcode theres an option to add launch images. I added it and it displays for 2 seconds... I want it to be more... How can i change it? Thanks :)

    • EmilioPelaez
      EmilioPelaez about 12 years
      You shouldn't do that. If you show the default image for longer than necessary, it will seem like your app is slow, and that's bad user experience. They already have your app, there's not need to rub your brand in the user's face.
    • rob mayoff
      rob mayoff about 12 years
      Keeping your launch image up longer is a great way to gather 1-star reviews.
    • Matan
      Matan about 12 years
      I dont mean longer as in 10 seconds... only 5... 3 seconds longer
    • jscs
      jscs about 12 years
      possible duplicate of Change iPhone splash screen time
  • Matan
    Matan about 12 years
    hi.. what should i write after the selector performSelector: and after the withObject: im new to xcode
  • Magic Bullet Dave
    Magic Bullet Dave about 12 years
    The selector is the method that you want to run next in the sequence and you use @selector(myMethod) after the performSelector. The withObject is an object you can pass to the method as a argument, if you have no arguments then use nil. Use NSNumber if your argument is a value. The delay is the number of seconds to wait before running it.
  • Vineesh TP
    Vineesh TP over 11 years
    My launching image doesn't always appear. I want to show launch image when I open application How can I set this .
  • Rupesh
    Rupesh over 11 years
    the above code is for showing launching image for longer time. You can use apple default by adding Default.png in your resources directory. At run time it automatically finds Default.png and shows when app opens.
  • Rupesh
    Rupesh over 11 years
    Answer about "My launching image doesn't always appear" is that app is not killed, when you killed the app from background process. then only it will show the Default.png
  • Vineesh TP
    Vineesh TP over 11 years
    Now testing, when I load first time. It works fine in device then I click on home button again Open it The launching images doesn't come. But, in Simulator showing launch image.
  • Rupesh
    Rupesh over 11 years
    double click the home button, now long press your app, delete it. Now open app, it will show the launching image
  • Vineesh TP
    Vineesh TP over 11 years
    It is working fine on Simulator but, not working on iPad device
  • Rupesh
    Rupesh over 11 years
    Just Do one thing create a viewcontroller class, place a image which you want to show as launcher image, In that class write following code
  • Rupesh
    Rupesh over 11 years
    -(void) viewWillAppear:(BOOL)animated { [self performSelector:@selector(dismiss1) withObject:nil afterDelay:5.0f]; [super viewWillAppear:animated]; } -(void) dismiss1 { [self dismissModalViewControllerAnimated:NO]; }
  • Maziyar
    Maziyar almost 11 years
    awesome! 2 seconds is enough to show off the brand and not piss of the users. Way better than blink of an eye! tnx
  • rmaddy
    rmaddy over 7 years
    DO NOT do this. Very bad.
  • rmaddy
    rmaddy over 7 years
    DO NOT do this. Very bad.