Swift ios set a new root view controller

前端 未结 20 909
醉话见心
醉话见心 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:11

    Swift 4, 5, 5.1

        let story = UIStoryboard(name: "Main", bundle:nil)
        let vc = story.instantiateViewController(withIdentifier: "NewViewController") as! NewViewController
        UIApplication.shared.windows.first?.rootViewController = vc
        UIApplication.shared.windows.first?.makeKeyAndVisible()
    

提交回复
热议问题