Why I can’t see Launch Screen when change Root View in swift5?

the problem I have is to remove the root arrow on the story board and set up the root view in the **AppDelegate** file to dynamically change the RootView.

 

 

There is no problem moving the root view, but the existing `splashScreen(Launch Screen)` is not visible. Why can’t you see it? How can I see the `splashScreen(Launch Screen)` and go to the root view?

 

 

**Main.Storyboard**

 

 

https://ifh.cc/g/0LXBV.png

 

 

**Login.Storyboard,**

 

 

https://ifh.cc/g/CtlFX.png

 

 

**Launch.Storyboard**

 

 

https://ifh.cc/g/pps62.png

 

 

 

 

**Move Root Screen in  AppDelegate.swift**

 

 

~~~swift

var window: UIWindow?


    func switchStartUI() {
        let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let viewController = mainStoryboard.instantiateViewController(withIdentifier: "StartViewController")
        self.window?.rootViewController = viewController
    }
   
    func switchToMainUI() {
        let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
        let viewController = mainStoryboard.instantiateViewController(withIdentifier: "NavigationController")
        self.window?.rootViewController = viewController
    }
   
    func switchLoginUI(_ pushtype : String) {
        let loginStoryboard = UIStoryboard(name: "Login", bundle: nil)
        let viewController = loginStoryboard.instantiateViewController(withIdentifier: "MainLoginController") as! MainLoginController
        viewController.pushType = pushtype
        self.window?.rootViewController = viewController
    }


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        self.window = UIWindow(frame: UIScreen.main.bounds)
      if let screenData : String = LocalStorage.get("ScreenView") as? String {
            switch (screenData) {
            case "success":
                switchToMainUI()
            case "success1":
                switchLoginUI("")
            case "success2":
                switchLoginUI("")
            default:
                switchStartUI()
            }
        } else {
            switchStartUI()
        }
       
        self.window?.makeKeyAndVisible()
       
        return true
    }

~~~

 

 

I want to see the splash screen and move on to the root view

 

 

There is already an image on my splash screen. It worked normally. But I can’t see the splash screen after dynamically modifying the root view. I’m the same

 

 

help me a lot

Powered by WPeMatico

About

You may also like...

Comments are closed.