Creating a navigationController programmatically (Swift)

后端 未结 6 364
盖世英雄少女心
盖世英雄少女心 2020-11-29 19:21

I\'ve been trying to redo the work on my app programmatically. (Without the use of storyboards)

I\'m almost done, except making the navigation controller manually.

6条回答
  •  清酒与你
    2020-11-29 19:36

     self.window = UIWindow(frame: UIScreen.main.bounds) 
     let storyboard = UIStoryboard(name: "Main", bundle: nil) 
     let storyboard_Secondary = UIStoryboard(name: "Secondary", bundle: nil) 
     var initialViewController = UIViewController() 
    
     let aUser = CommonMethods.loadCustomObject("\(Constants.kUserProfile)") as? User  
     if aUser?.respCode == 1 { 
        initialViewController = storyboard_Secondary.instantiateViewController(withIdentifier: "MainTabVC")
        UIApplication.shared.statusBarStyle = .lightContent
        let navigationController = UINavigationController(rootViewController: initialViewController)
        navigationController.isNavigationBarHidden = true
        self.window!.rootViewController = navigationController
        self.window!.makeKeyAndVisible() 
    }
    

提交回复
热议问题