I want to set one of my ViewControllers from my navigation stack as my apps window.rootViewController while I am somewhere in another controller's navigation stack. That other controller is currently my window.rootViewController. Therefore I use this code:
if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
appDelegate.window?.rootViewController = self
}
This results in just a black screen. When I instantiate a new ViewController from Storyboard it's working fine, but all entries are gone. I don't want to reconfigure the new viewController, if that is avoidable.
Update A
I put self to a strong reference in appDelegate to check that, because I thought it's view was unloaded somewhere on the way, but it still resulted in a black screen.
The documentation says: The root view controller provides the content view of the window. Assigning a view controller to this property (either programmatically or using Interface Builder) installs the view controller’s view as the content view of the window. The new content view is configured to track the window size, changing as the window size changes. If the window has an existing view hierarchy, the old views are removed before the new ones are installed.
Clarification: I don't want to instantiate a new VC, I want to use the current one, without putting a navigationController around it, it should not be necessary. I'm sure it is possible without any workaround, I am just missing something here.
UIViewController
which is on anotherUIViewController
-stack already and put it on its own stack? – Prostration