Set rootViewController of UINavigationController by method other than initWithRootViewController

后端 未结 5 781
死守一世寂寞
死守一世寂寞 2020-12-02 11:45

How Do I set the rootViewController of UINavigationController by a method other than initWithRootViewController?

I want use

5条回答
  •  渐次进展
    2020-12-02 12:34

      let storyboard = UIStoryboard(name: "Main", bundle: nil)         
      let yourNewRootView = storyboard.instantiateViewControllerWithIdentifier("yourNewRootView") as? yourNewRootView
    
    
       self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
    
        UIView.transitionWithView(self.window!, duration: 0.1, options: [UIViewAnimationOptions.TransitionFlipFromRight,UIViewAnimationOptions.TransitionFlipFromLeft], animations: 
        {
            // animation
    
            }, completion: { (finished: Bool) -> () in
    
                self.window?.rootViewController = nil
                self.window?.rootViewController = yourNewRootView
                self.window?.makeKeyAndVisible()
        })
    

提交回复
热议问题