I've been reading several posts dealing with switching the rootViewController
of the window, and sometimes it is said that keeping a same rootViewController
throughout the app's lifecycle is better than switching it, and other posts are related to changing the rootViewController
at some point of the app. I'm confused about this, and I couldn't find any recommendation regarding this point in Apple's docs.
What should be the best practice when you are likely to have different content view controllers in an app? For example, let's say you have a tabbed app (UITabBarController
) that you want first to show a welcome view for signing in or signing up (UINavigationController
):
1) Approach with a fixed rootViewController
. I think you should set the UITabBarController
as the rootViewController
, as the core of the app is tabbed, but if user credentials are needed, then set a UINavigationController
within the UITabBarController
, hiding the tab bar, to push the welcome view and navigate to Sign In/Sign Up view controllers.
2) Approach switching rootViewController
. Firstly, if user credentials needed, set the UINavigationController
as the rootViewController
to show the welcome view and navigate to Sign In/Sign Up, and, once user credentials successfully provided or account successfully created, switch the rootViewController
to the UITabBarController
to show the core tabbed app.
In case the best general approach is switching rootViewController
as needed, what are the memory management considerations you'd take into account? Should I need to have two strong
properties in AppDelegate (UITabBarController
and UINavigationController
)? And what about the transition between the view controllers when switching the rootViewController
: will it be smooth, or should you animate it?
Thanks in advance