Reputation: 456
im using a Default.png file for my iPad-app. It appears correctly but i could'nt find a way to modify the duration of the splash screen. Has somebody any suggestions? Google has many sites that show how to setup the startscreen but could'nt find a solution for my problem.
Upvotes: 4
Views: 22872
Reputation: 4803
As @Conrad Shultz answered, splash screen should be used only via the supplied LaunchScreen.storyboard
file by Xcode.
However, in rare situations you do want to prolong the splash screen:
This is the way to do it:
Inside AppDelegate
, under didFinishLaunchingWithOptions
you should:
The code:
let splashVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "splash")
window?.makeKeyAndVisible()
if let root = window?.rootViewController
{
root.present(splashVC, animated: false, completion: nil)
let dispatchTime = DispatchTime.now() + 3
// didFinishLaunchingWithOptions will return and this block will be executed afterwards, hence, async..
DispatchQueue.main.asyncAfter(deadline: dispatchTime, execute: {
root.presentedViewController?.dismiss(animated: false, completion: nil)
})
}
}
Upvotes: 0
Reputation: 8808
The first rule of Human Interface Guidelines for Splash Screens is: don't use splash screens. The second rule is: don't use splash screens!:
Supply a launch image to improve user experience.
Avoid using your launch image as an opportunity to provide:
An “application entry experience,” such as a splash screen
An About window
Branding elements, unless they are a static part of your application’s first screen
If you absolutely must include a long-duration splash screen, and have darn good reasons for doing so, the usual approach is to throw up a UIImageView
containing a copy of you launch image in, e.g., application:didFinishLaunchingWithOptions:
- which should provide the illusion of a lengthy splash screen.
But please don't.
Upvotes: 17
Reputation: 9078
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.
Upvotes: 0
Reputation: 565
You can't technically modify the duration that the "Default" image stays there; it is designed to just be a temporary image "foreshadowing" the app actually starting up and isn't specifically designed as a splash screen.
I recommend that you keep the "splash screen effect" by adding an image view to the screen as the app starts in the -application:didFinishLaunchingWithOptions: method. You can then set a timer which calls a method to animate the splash off after the designated time you want it to be. It will be there for a little longer than you specify depending on how long it actually took the app to load up, but it will give the effect you're after.
You can set the image view's image to [UIImage imageNamed:@"Default"] and it will access that Default artwork for you.
Upvotes: 1
Reputation: 10005
Using a "splash screen" (Logo, etc) is not the idea of the Default.png!
Read the HIG from Apple.
The (splash) screen (named loading screen) is not for a Logo showing or something like this. When having multitasking enabled, the "splash screen" shows up really rare. The splash screen should, like the apple apps does, only show the interface coming up in the first application screen without any localized strings, etc.
Also keep in mind: The faster the iOS Device get, the shorter you can see the Default.png. So avoid using it for any important CI/CD content.
Upvotes: 10
Reputation: 2535
You can't change the duration. If you want it be shown longer though, you can add the same image to a view that you show while you're loading your data!
Upvotes: 0
Reputation: 27506
The Default image is displayed while the app is loading and will be dismissed as soon as the app is ready. And there is no API to control that duration.
Upvotes: 6