My application also handles some authorization flow (PIN-Registration). I work with two storyboards. One for the Registration/Login Progress (Login.storyboard) and one when the user is connected to the service.
The following code is under application:didFinishLaunchingWithOptions: after some initializations:
// Set rootview (Check if user is registred)
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
if ([ccmpService isRegistered]) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
self.window.rootViewController = [storyboard instantiateInitialViewController];
if (launchOptions) {
NSDictionary *remoteNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
[self handleRemoteNotifications:remoteNotif];
}
} else {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Login" bundle:nil];
self.window.rootViewController = [storyboard instantiateInitialViewController];
}
[self.window makeKeyAndVisible];
return YES;
When i want to change the storyboards (Login / Logout) i call something like (also declared in the App Delegate:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *sourcetVC = self.window.rootViewController;
UIViewController *destVC = [storyboard instantiateInitialViewController];
[UIView transitionFromView: sourcetVC.view
toView: destVC.view
duration: 0.5
options: UIViewAnimationOptionTransitionFlipFromRight
completion: ^(BOOL finished) {
self.window.rootViewController = destVC;
}];