Swift 3
This is doable in a safe way by presenting the splash controller for what ever time you specify then remove it and display your normal rootViewController.
In AppDelegate you can create these 2 methods:
private func extendSplashScreenPresentation(){
// Get a refernce to LaunchScreen.storyboard
let launchStoryBoard = UIStoryboard.init(name: "LaunchScreen", bundle: nil)
// Get the splash screen controller
let splashController = launchStoryBoard.instantiateViewController(withIdentifier: "splashController")
// Assign it to rootViewController
self.window?.rootViewController = splashController
self.window?.makeKeyAndVisible()
// Setup a timer to remove it after n seconds
Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(dismissSplashController), userInfo: nil, repeats: false)
}
2.
@objc private func dismissSplashController() {
// Get a refernce to Main.storyboard
let mainStoryBoard = UIStoryboard.init(name: "Main", bundle: nil)
// Get initial viewController
let initController = mainStoryBoard.instantiateViewController(withIdentifier: "initController")
// Assign it to rootViewController
self.window?.rootViewController = initController
self.window?.makeKeyAndVisible()
}
Now you call
self.extendSplashScreenPresentation()
in didFinishLaunchingWithOptions.
You are set to go...