Skip to content

Instantly share code, notes, and snippets.

@djibouti33
Last active December 20, 2015 12:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djibouti33/6129555 to your computer and use it in GitHub Desktop.
Save djibouti33/6129555 to your computer and use it in GitHub Desktop.
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UINavController *centerNav = [[UINavController alloc] initWithRootViewController:[FeaturedViewController new]];
centerNav.restorationIdentifier = @"centerNav";
UINavigationController *leftDrawerNavController = [[UINavigationController alloc] initWithRootViewController:[LeftDrawerViewController new]];
leftDrawerNavController.restorationIdentifier = @"leftDrawerNav";
MMDrawerController *drawerViewController = [[MMDrawerController alloc] initWithCenterViewController:centerNav leftDrawerViewController:leftDrawerNavController];
// no restoration class, since this will always be created before state restoration resumes, and therefore will be found implicitly
[drawerViewController setRestorationIdentifier:@"mmDrawer"];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = drawerViewController;
self.window.restorationIdentifier = NSStringFromClass([UIWindow class]);
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return true;
}
- (UIViewController *)application:(UIApplication *)application viewControllerWithRestorationIdentifierPath:(NSArray *)identifierComponents coder:(NSCoder *)coder
{
if ([[identifierComponents lastObject] isEqualToString:@"leftDrawerNav"]) {
return ((MMDrawerController *)self.window.rootViewController).leftDrawerViewController;
}
if ([[identifierComponents lastObject] isEqualToString:@"centerNav"]) {
return ((MMDrawerController *)self.window.rootViewController).centerViewController;
}
return nil;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment