Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LaunchScreen.storyboard not opening Main.storyboard Navigation Controller

I have just started to develop a new application using Swift (newbie). I have

  1. LaunchScreen.storyboard with just a image of my splash screen
  2. I have a Main.storyboard with a Navigation Controller connected to two segues, Home and Registration.
  3. In the ViewController.swift, inside the viewDidLoad I am deciding which segue to call
  4. My Main.Storyboard does not have a rootViewController, I need to decide which viewController to display at run time.

    if (Settings.hasRegistrationCompleted()) {
        performSegue(withIdentifier: "Home", sender: nil)
    } else {
        performSegue(withIdentifier: "Registration", sender: nil)
    } 
    

My questions

  1. I put a breakpoint on the first line if (Settings.has and the breakpoint never reaches here
  2. LaunchScreen lasts only for 2 seconds (tested on my Simulator) how do I increase it

EDIT

I have Main set as the Main Interface on my project. I did a Clean build and tried again, did not work.

Also below is the Main.Storyboard

enter image description here

like image 690
Siddharth Avatar asked Jan 04 '23 09:01

Siddharth


1 Answers

in here two things you need to identify

first

check your storyboard name Main.storyboard are attached properly in your Target -> general -> Deployment Info -> main Interface, for e.g like this

enter image description here

second

check your Intial VC connected with navigation Controller and ensure your Initial VC as Root controller

enter image description here

update answer

initially set Stroryboard ID and for each VC

enter image description here

there after change the Root controller in appdelegate

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    self.window = UIWindow(frame: UIScreen.main.bounds)
    // Override point for customization after application launch.
     let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let rootViewController: UIViewController?
     if (Settings.hasRegistrationCompleted()) {
     rootViewController = storyboard.instantiateViewController(withIdentifier: "HomeVC")
    }else
     {
         rootViewController = storyboard.instantiateViewController(withIdentifier: "RegistrationVC")
    }
     let navigation = UINavigationController(rootViewController: rootViewController!)
    self.window?.rootViewController = navigation
    self.window?.makeKeyAndVisible()
    return true
}
like image 94
Anbu.Karthik Avatar answered Jan 29 '23 19:01

Anbu.Karthik