I'm trying to change RootViewController with another ViewController. But I can't figure it out. I'm facing some problems that are
After changed rootViewController by above code then new viewController is disappear. In console log : Presenting view controllers on detached view controllers is discouraged . Please help me!
My code is :
func changeRootView(){
guard let delegate = UIApplication.shared.delegate else {
return
}
guard let window = (delegate as! AppDelegate).window else {
return
}
UIView.transition(with: window, duration: 0.3, options: .transitionCrossDissolve, animations: {
let lgv = DriverMainViewController()
window.rootViewController = UINavigationViewController(rootViewController: lgv)
}, completion: { completed in
SideMenuManager.menuLeftNavigationController!.dismiss(animated: true, completion: nil)
print ("changed")
})
}
Then changeRootView function changed App keyWindow's rootViewController
But this blue backgrounded viewController is disappeared in 1 second. This screen shot is after disappeared new root view controller.