iOS 13: Swift - 'Set application root view controller programmatically' does not work

后端 未结 14 1057
北恋
北恋 2020-12-01 01:43

I have following code in my AppDelegate.swift to setup root view controller for an iOS application. But it does not work. It follows Target structure (defined under General

14条回答
  •  独厮守ぢ
    2020-12-01 02:42

        let MainViewController  = mainStoryboard.instantiateViewController(withIdentifier: "MainViewController") as! MainViewController
    
                        let nvc:rootNavigation  = mainStoryboard.instantiateViewController(withIdentifier: "rootNavigation") as! rootNavigation
                        nvc.viewControllers = [Mainmap]
                       
                        leftViewController.mainViewController = nvc
    
    UIApplication.shared.windows.first?.backgroundColor = UIColor(red: 236.0, green: 238.0, blue: 241.0, alpha: 1.0)
                        UIApplication.shared.windows.first?.rootViewController = nvc
                        UIApplication.shared.windows.first?.makeKeyAndVisible()
    

提交回复
热议问题