For the new user I have several onboarding screens (all of them are in the same OnboardViewController
). If user is successfully registered, I'd change the root controller of my app from OnboardViewController
to PreLoadViewController
:
let mcVC = PreLoadController()
appDelegateTemp.window?.rootViewController = mcVC
I'm using this controller to display progress of the content loading. After the content is loaded, I'm changing the root controller once again:
if let appDelegateTemp = UIApplication.shared.delegate as? AppDelegate {
let mcVC = MainViewController()
let navy = UINavigationController(rootViewController: mcVC)
appDelegateTemp.window?.rootViewController = navy
}
It works, but I have a very strange bug. When I'm trying to change settings (like, mic settings
or notifications settings
) from the app, I have to go to iPhone settings:
if let settingsUrl = URL(string: UIApplication.openSettingsURLString) {
UIApplication.shared.open(settingsUrl)
}
But when I'm back I'm shown the OnboardViewController
again as if appDelegate doesn't remember that current root controller is mcVC
(or, rather, UINavigationController
with embed mcVC
).
So, why is that, and what is the right way to fix this?