Swift ios set a new root view controller

前端 未结 20 895
醉话见心
醉话见心 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 05:03

    You can use this code when you click the login button :-

    let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
    var vc = mainStoryboard.instantiateViewControllerWithIdentifier("respectiveIdentifier") as ViewController  
    UIApplication.sharedApplication().keyWindow.rootViewController = vc
    

提交回复
热议问题