[ios] Displaying splash screen for longer than default seconds

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.

  1. First in LaunchingScreen.storyboard give your controller a StoryBoard identifier let's say "splashController"
  2. In Main.storyboard give your initial viewController a StoryBoard identifier let's say "initController". -This could be nav or tab bar etc...-

In AppDelegate you can create these 2 methods:

  1. 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...

Examples related to ios

Adding a UISegmentedControl to UITableView Crop image to specified size and picture location Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Keep placeholder text in UITextField on input in IOS Accessing AppDelegate from framework? Autoresize View When SubViews are Added Warp \ bend effect on a UIView? Speech input for visually impaired users without the need to tap the screen make UITableViewCell selectable only while editing Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

Examples related to objective-c

Adding a UISegmentedControl to UITableView Keep placeholder text in UITextField on input in IOS Accessing AppDelegate from framework? Warp \ bend effect on a UIView? Use NSInteger as array index Detect if the device is iPhone X Linker Command failed with exit code 1 (use -v to see invocation), Xcode 8, Swift 3 ITSAppUsesNonExemptEncryption export compliance while internal testing? How to enable back/left swipe gesture in UINavigationController after setting leftBarButtonItem? Change status bar text color to light in iOS 9 with Objective-C

Examples related to splash-screen

Adding a splash screen to Flutter apps How To fix white screen on app Start up? android splash screen sizes for ldpi,mdpi, hdpi, xhdpi displays ? - eg : 1024X768 pixels for ldpi Android splash screen image sizes to fit all devices How to build splash screen in windows forms application? Displaying splash screen for longer than default seconds How do I make a splash screen? What are the sizes used for the iOS application splash screen?