I have a simple iPhone application that loads very quickly, so the splash screen only displays for a fraction of a second. Is there any way to control how long the splash screen displays? I have searched around, and have not found anything that seems like it would work. Do I have to create a subview with my splash image? How would I control its display time and switch between the subview and the mainview?
-
3Extending the duration of the splash screen gives the user the impression that your app is slow and takes a long time to load. That's the opposite from what you want on an iPhone, if your app is slow, people are not gonna like it and they're gonna delete it. – EmilioPelaez Apr 10 '12 at 18:55
-
1i understand your point and it makes perfect sense. however, for my case I am not submitting it to the app store it is for a software class and I just need my name and logo to appear long enough to see. thanks – Joey Apr 10 '12 at 19:04
-
There is a good blog post here on how to create a splash screen using a `UIImageView` with a timer: http://nullpointr.wordpress.com/2012/02/19/iphone-dev-how-to-implement-a-splash-screen/ Useful for beginners, who are still learning the best way to do things in iOS. – asgeo1 Apr 11 '14 at 03:53
4 Answers
While I agree with the views expressed here and in the other question about why you should not "abuse" the default screen, it seems to me quite trivial to achieve this effect:
When starting up, simply put up a view that looks exactly like the splash screen and use an NSTimer
to dismiss it. Really quite easy.
// viewDidLoad
[self performSelector:@selector(dismiss)
withObject:nil
afterDelay:yourTimeIntervalInSectons];
// dismiss
[self performSegueWithIdentifier:@"ID" sender:nil];
However, don't have the splash screen come on each time the application becomes active. I once did this for a very specific and useful purpose in the context of my app - but Apple rejected it. Hey, they even called me on Saturday evening to explain it to me.

- 79,884
- 17
- 117
- 140
-
8I mean - how are you going to learn programming if you do not want to solve this simple problem yourself?? See code above, and please up vote and tick the checkmark. – Mundi Apr 10 '12 at 19:06
While I agree with all that's been told here, I had to implement a splash screen with a timer once as well, so here's the code:
- (void)showSplashWithDuration:(CGFloat)duration
{
// add splash screen subview ...
UIImage *image = [UIImage imageNamed:@"Default.png"];
UIImageView *splash = [[UIImageView alloc] initWithImage:image];
splash.frame = self.window.bounds;
splash.autoresizingMask = UIViewAutoresizingNone;
[self.window addSubview:splash];
// block thread, so splash will be displayed for duration ...
CGFloat fade_duration = (duration >= 0.5f) ? 0.5f : 0.0f;
[NSThread sleepForTimeInterval:duration - fade_duration];
// animate fade out and remove splash from superview ...
[UIView animateWithDuration:fade_duration animations:^ {
splash.alpha = 0.0f;
} completion:^ (BOOL finished) {
[splash removeFromSuperview];
}];
}
Just call the function somewhere in your AppDelegate's -applicationDidFinishLaunching:withOptions:
method
@asgeo1: code works just fine for me (I've used similar code in several projects). I've added an example project on my Dropbox for your convenience.

- 11,779
- 7
- 51
- 92
-
I don't think this works. This is no different to just calling sleep(); In my tests, I could change "Default.png" to a non-existent image - "DoesNotExist.png", and it would still show the 'splash' screen for the duration - but only because it was sleeping. It doesn't actually render the referenced image at all. I wouldn't recommend this approach. – asgeo1 Apr 11 '14 at 01:48
-
@asgeo1: for your convenience I've added an example project so you can see for yourself that the code works fine. – Wolfgang Schreurs Apr 11 '14 at 14:35
-
Thanks for the example. But I don't think you've understood what I've said. Yes - putting a sleep() call will cause the "loading image" (as specified in the plist) to show for a duration. But the rest of your code is redundant. The bit there that creates the UIImageView *doesn't work*. Don't believe me? Try changing `Default.png` to some other image. It won't work - the default image is showing because that's just iOS showing the loading image from the plist (`UILaunchImageName`), not because you've added a UIImageView to the window! – asgeo1 Apr 13 '14 at 00:20
-
You can delete all of your code except for the call to `sleepForTimeInterval` and you get the same result. My point, is that blocking the thread is not the best way to do this. See this example on how it should be done: http://nullpointr.wordpress.com/2012/02/19/iphone-dev-how-to-implement-a-splash-screen/ – asgeo1 Apr 13 '14 at 00:21
Don't do this and/or read why here
iOS Duration of Splash Screen (Default.png)
It does really make no sense to extend the duration of the Default.png.

- 1
- 1

- 9,965
- 3
- 48
- 60
Now, I completely agree with the above posts that you shouldn't do this, but if you still wish to it can be achieved very easily by adding the following to your AppDelegate.m
.
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
sleep(2);
}
The "2" represents how many seconds to sleep for. It will accept values like ".5"

- 129,200
- 40
- 280
- 281
-
No working for me as it gives a blank when transition from view to another – Mohamed Saleh Nov 26 '15 at 17:40