Making the launch image display longer xcode
Asked Answered
P

8

15

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 :)

Petrinapetrine answered 26/2, 2012 at 8:14 Comment(4)
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.Best
Keeping your launch image up longer is a great way to gather 1-star reviews.Deanery
I dont mean longer as in 10 seconds... only 5... 3 seconds longerPetrinapetrine
possible duplicate of Change iPhone splash screen timePhlebotomize
H
12

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

Hauptmann answered 27/2, 2012 at 10:16 Comment(8)
My launching image doesn't always appear. I want to show launch image when I open application How can I set this .Theodicy
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.Hauptmann
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.pngHauptmann
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.Theodicy
double click the home button, now long press your app, delete it. Now open app, it will show the launching imageHauptmann
It is working fine on Simulator but, not working on iPad deviceTheodicy
Just Do one thing create a viewcontroller class, place a image which you want to show as launcher image, In that class write following codeHauptmann
-(void) viewWillAppear:(BOOL)animated { [self performSelector:@selector(dismiss1) withObject:nil afterDelay:5.0f]; [super viewWillAppear:animated]; } -(void) dismiss1 { [self dismissModalViewControllerAnimated:NO]; }Hauptmann
S
18
- (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....
}
Shaun answered 26/2, 2012 at 13:0 Comment(2)
awesome! 2 seconds is enough to show off the brand and not piss of the users. Way better than blink of an eye! tnxAmund
DO NOT do this. Very bad.Enos
H
12

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

Hauptmann answered 27/2, 2012 at 10:16 Comment(8)
My launching image doesn't always appear. I want to show launch image when I open application How can I set this .Theodicy
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.Hauptmann
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.pngHauptmann
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.Theodicy
double click the home button, now long press your app, delete it. Now open app, it will show the launching imageHauptmann
It is working fine on Simulator but, not working on iPad deviceTheodicy
Just Do one thing create a viewcontroller class, place a image which you want to show as launcher image, In that class write following codeHauptmann
-(void) viewWillAppear:(BOOL)animated { [self performSelector:@selector(dismiss1) withObject:nil afterDelay:5.0f]; [super viewWillAppear:animated]; } -(void) dismiss1 { [self dismissModalViewControllerAnimated:NO]; }Hauptmann
R
2

You can use the sleep() method.

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
    sleep(10);
    return YES;
}
Romeyn answered 15/3, 2013 at 4:48 Comment(1)
DO NOT do this. Very bad.Enos
M
1

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:

Micahmicawber answered 26/2, 2012 at 8:27 Comment(2)
hi.. what should i write after the selector performSelector: and after the withObject: im new to xcodePetrinapetrine
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.Micahmicawber
S
1

In Swift

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        Thread.sleep(forTimeInterval: 2.0)
        return true
}
Sallet answered 29/8, 2017 at 6:46 Comment(0)
E
0

make the default view...have an image view with the same default image...and then launch the new view(main app ) after specific time using [self performselector methods

Edgardoedge answered 26/2, 2012 at 8:25 Comment(0)
P
0

you can put a UIImageView in your very first loaded view. say, in viewDidLoad of FirstViewController

-(void)viewDidLoad{
 appLogo = [UIImageView alloc]initWithImage:[UIImage imageNamed:@"companyLogo.png"]];
 [appLogo setFrame:CGRectMake..... ];
 self.view addSubView:appLogo];

 [self performSelector:@selector(hideAppLogo) withObject:nil afterDelay:1000000 :) ];
}

-(void)hideAppLogo{
 [appLogo setHidden:YES];
 //let the user use your app now!
}
Puma answered 27/2, 2012 at 14:9 Comment(0)
G
0

YOu can achieve this by adding backgroundColor of "Default.png" in window before assigning window to rootviewController and just after few seconds assign rootviewController to window and set window background color to its default.

like this -

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
 [self performSelector:@selector(openLoginScreen) withObject:nil afterDelay:0.5];
 self.window.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Default.png"]]; 
 [self.window makeKeyAndVisible];
}

-(void)openLoginScreen{
self.window = [UINavigation .... "YOUR ROOT VIEWCONTROLLER"];     
}
Gloam answered 7/11, 2012 at 5:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.