I am a rookie in Swift. I have a initial viewController within a navigationController. Inside that is a tableView. When i click on the add button item in the NavigationBar a new viewController is present modaly. Now i click a another button in the presented Vc and the presented Vc is dismiss. The root Vc is present now. But i will show a new root vc. I will set a new root Vc when dismiss the second Vc.
Can i set a new root Vc programmaticly when i dismiss a second vc?
Try this out,
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let newViewController = storyBoard.instantiateViewController(withIdentifier: "YourViewController") as! YourViewController
let navigationController = UINavigationController(rootViewController: newViewController)
let appdelegate = UIApplication.shared.delegate as! AppDelegate
appdelegate.window!.rootViewController = navigationController
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With