Reputation: 13095
Say Storyboard A has a navigation controller and 5 view controllers, and contains the "signup" portion of an app. After the last step in the signup process, I want to transition to Storyboard B, which contains the main part of the app. I can get to Storyboard B like this:
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *initialViewController = [mainStoryboard instantiateInitialViewController];
[self.navigationController presentViewController:initialViewController animated:YES completion:^ {
}];
This works, but all of Storyboard A's view controllers stay in memory. I also don't want to push Storyboard B onto the navigation stack of Storyboard A's navigation controller, because Storyboard B has it's own custom navigation.
So what's the best way to deal with this situation? I need to get to Storyboard B, but I need the app to completely forget about Storyboard A after the transition is made.
Upvotes: 0
Views: 282
Reputation: 104082
Reset the window's root view controller to the initial controller in your storyboard B, and this will cause the whole navigation stack associated with Storyboard A to be deallocated,
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *initialViewController = [mainStoryboard instantiateInitialViewController];
self.view.window.rootViewController = initialViewController;
Upvotes: 1