Swift ios set a new root view controller

前端 未结 20 872
醉话见心
醉话见心 2020-12-13 04:46

I wonder if its possible to set a new root VC?

My app gets init with a uinavigation controller that has a table view to be the root VC.

Then from the table v

20条回答
  •  既然无缘
    2020-12-13 04:52

    Any view controller you want to set root just call the below function like

      UIApplication.shared.setRootVC(vc)
    
      extension UIApplication {
    
        func setRootVC(_ vc : UIViewController){
    
            self.windows.first?.rootViewController = vc
            self.windows.first?.makeKeyAndVisible()
    
          }
      }
    

提交回复
热议问题