20

for iOS devices, after set a custom launch time image, when tested on simulator it remains about 4s but when tested on iphone it is hide after less than 1s! Assumed that depends on processor but how to modify that visualization time?? Thanks.

Ruth85
  • 645
  • 2
  • 7
  • 12

4 Answers4

43

Better option would be to put a sleep of 5 seconds in your appDidFinishLaunching: method.

Statement at the start of your appDidFinishLaunching: method.

sleep(5);

Hope this helps you.

Note:- You may want to increase the time from 5 seconds to whatever time that is suitable for you. Thanks

EDIT: You may need to include #import <unistd.h> statement.

Meet Doshi
  • 4,241
  • 10
  • 40
  • 81
Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216
  • 1
    Please do mention the reason for downvoting. So that we can improve and learn from our mistakes. – Parth Bhatt Dec 02 '11 at 08:24
  • good. My solution is set up the root controller for window, and then start the threads to do jobs like version checking, dada preloading, then sleep, then return YES. After the launching image, all the things are ready. Perfect. – Henry Sou Sep 10 '12 at 22:37
  • 1
    down voted because it shows bad behaviour. delaying to a show a spash it really frowned upon by some customers but also by apple – Daij-Djan Dec 10 '13 at 23:17
  • @Daij-Djan: Read the question first and then down vote. Question wants the increase in launch image time. So as per the question answer should be ok. Here question is about Correct and Wrong, not Good or Bad. Anyways – Parth Bhatt Dec 11 '13 at 13:31
  • 1
    it is technically correct but bad advice. blocking the main thread is NEVER EVER a good way. bringing up a custom view like proposed by sheen is the way to go. – Daij-Djan Dec 11 '13 at 14:54
  • blocking can even get an app killed and is never ok -- Im aware there are different opinions on the matter – Daij-Djan Dec 11 '13 at 14:55
  • but that is my reason for voting like I did – Daij-Djan Dec 11 '13 at 14:55
5

You can't actually change of the loading time itself - that's decided by the operating system and how it takes to load. BUT - you can make it feel like it takes longer by simply putting a UIImageView with your image on top of your main window application and removing it using an NSTimer - you can even use nicer animations to make it disappear like make it fade out.

Meet Doshi
  • 4,241
  • 10
  • 40
  • 81
shein
  • 1,834
  • 15
  • 23
  • 4
    Remark though that I as a customer would really hate such a thing. And with really I mean that I would try to get a refund after writing a bad review. – JustSid Aug 21 '11 at 08:16
  • 5
    To extend what JustSid says - apple highly discourages this practice and in general did not intend the images to be splash screen but as a loading screen – shein Aug 21 '11 at 08:28
5

We can also increase the duration time of App Launch Image by implement applicationShouldLaunch as below,

#import "MSTRMobileAppDelegate.h

@implementation MSTRMobileAppDelegate (Extension)

- (BOOL)applicationShouldLaunch:(UIApplication *)application errorDescription:(NSString**)errorString
{   
    sleep(10);

    return TRUE;
}

@end`
Meet Doshi
  • 4,241
  • 10
  • 40
  • 81
Chuck
  • 61
  • 1
  • 3
2

Add the sleep function to your this method below in your delegate class.
NOTE: the name of the method is NOT the same as suggested in the answers above.

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

    sleep(3); //PUT THE SLEEP HERE AND IT WILL HOLD YOUR LAUNCH IMAGE FOR HOWEVER SECONDS YOU "SLEEP"

    // Override point for customization after application launch.

    return YES;

    }

This worked for me. This post is intended for future seekers to this problem not that I'm trying to answer a question that was asked 2 years ago

BenMorel
  • 34,448
  • 50
  • 182
  • 322