how to set root view controller in ios programmatically swift code example
Example: swift go to root view controller
// For Navigation
self.navigationController?.popToRootViewController(animated: true)
// For Presenting modally
self.view.window!.rootViewController?.dismissViewControllerAnimated(false, completion: nil)