I am having some trouble with dismissing a collection of UIViewController objects. I do not know of an elegant way to dismiss all loaded modal UIViewController objects at once.
I make use of the "storyboard" in Xcode 4, but I do not use Segues to map the screens. I use dynamic code, like so:
It all starts in MainViewController.m. I load [myMenuController] (a menu list). When the user selects an option from the menu, it then loads [myTicketController]. After some user interaction there, it loads [myNextController] and you see the pattern. I load several UIViewControllers dynamically (no segues here):
//from MainViewController.m - Load the main menu
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
myMenuController = (MyMenuController *)[storyboard instantiateViewControllerWithIdentifier:@"MyMenuController"];
myMenuController.settingsModel = settingsModel;
myMenuController.ticketStatusHandler = data;
myMenuController.rootDataModel = dataModel;
[myMenuController setModalPresentationStyle:UIModalPresentationFullScreen];
[self dismissModalViewControllerAnimated:NO];
[self presentModalViewController:myMenuController animated:YES];
///////////////////////////////////////////////////////////////////////////
//from MyMenuController.m - Load the add ticket menu
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
myTicketController = (MyTicketController *)[storyboard instantiateViewControllerWithIdentifier:@"MyTicketController"];
myTicketController.settingsModel = settingsModel;
myTicketController.ticketStatusHandler = data;
myTicketController.rootDataModel = dataModel;
[myTicketController setModalPresentationStyle:UIModalPresentationFullScreen];
[self dismissModalViewControllerAnimated:NO];
[self presentModalViewController:myTicketController animated:YES];
///////////////////////////////////////////////////////////////////////////////
//from MyTicketController.m - Load the next screen
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
myNextController = (MyNextController *)[storyboard instantiateViewControllerWithIdentifier:@"MyNextController"];
myNextController.settingsModel = settingsModel;
myNextController.rootDataModel = dataModel;
[myNextController setModalPresentationStyle:UIModalPresentationFullScreen];
[self dismissModalViewControllerAnimated:NO];
[self presentModalViewController: myNextController animated:YES];
So I get to the end of the app and have loaded several more UIViewControllers. Let's say I load 4 or 5 more UIViewControllers after [myNextController] has been loaded.
Is there a generic way to unload all UIViewControllers that are in memory, and simply reload [myMenuController]?