Changing the rootViewController of a UIWindow Changing the rootViewController of a UIWindow ios ios

Changing the rootViewController of a UIWindow


It turns out there are two separate issues. 1) I had a retain cycle in Controller A so it was never getting dealloc'd. Secondly, in order to change the root view controller you must remove the windows subviews first (even though the docs suggest otherwise)


The problem could be in your implementation of ControllerA or ControllerB, they may retain 'self' in the code so ARC cant automatically dealloc you ViewController. Can you post you ControllerA and ControllerB implementation.


var loginNavigationController: OnBoardViewController?{    willSet{        if newValue == nil {            loginNavigationController?.view.removeFromSuperview()        }    }}

loginNavigationController = nil


matomo