Reputation: 18558
I'm building an app that does a ton of setup when the app loads. As such, I have a loading view that displays some information to the user while the setup takes place...
MyLoadingViewController *loadingViewController = [[MyLoadingViewController alloc] init];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = loadingViewController;
[self.window makeKeyAndVisible];
.
.
//Setup code happens here
.
.
MyHomeViewController *homeViewController = [[MyHomeViewController alloc] init];
self.window.rootViewController = homeViewController;
When the setup code completes, I want to transition into my home screen. Is setting the rootVewController to the new home view controller the proper way to do that kind of a transition?
Thanks so much for your wisdom!
Upvotes: 0
Views: 121
Reputation: 5092
I sometimes cheat a little by having the ViewController that does all the loading display an image that is the exact same as the default.png on screen while it loads, then animate it out once complete.
For example in my LoginViewController I firstly display the default image in viewDidLoad, contact the server for auto login and then fade out the image once the app logins. The user never notices as he just sees the default image fade out once the app is ready.
Upvotes: 1
Reputation: 104082
Yes, that's an ok way to do it -- you won't have any animation, but it should work fine. loadingViewController will be deallocated after you switch the root view controllers -- if that's not what you want, then you should create a property to point to it.
Upvotes: 1