I've set my launch screen to only display for 1 second using the code below sleep(1); in the app delegate, but when testing directly on a device, I have to wait for the full 5 seconds.
Every time I run a test using an iPhone, or an iPad, I have to wait the full 5 second default before the app will load, however, it works great in the simulator.
If I unplug the iPhone cable, the sleep() function works on the devices. Is there a setting in xCode for this?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
sleep(1);
...
}
In order to delay the launch screen this is not the recommended method. This just delays the whole process.
I recommend you add a new viewController
to the very beginning of your project which will show immediately after the launch screen with a UIImageView
containing the exact same image as the launch Image.
Then add a delay from there before switching to the original first screen. This way you can even add a new different kind of transition to the launch image.
#import "OrginalController.h"
- (void) gotoOrginalFirstScreen
{
// This function will take you to your oringinal first screen
// from the temporary screen with the launch image
OrginalController *controller = [[OrginalController alloc] initWithNibName:@"OrginalController" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:controller animated:YES completion:nil];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// add this line to call the transition and the delay
[self performSelector:@"gotoOrginalFirstScreen" withObject:nil afterDelay:1.0];
}