Search code examples
iosobjective-cios7

Dismiss Root Controller


I'm developing an application, and at some point I need a Modal ViewController to "become" the Root ViewController.

How can I dismiss the current rootController, and set my Modal as my new rootController?


Solution

  • First you have to set your root view controller nil.

      [self.window setRootViewController:nil];
       UIStoryboard *MainStoryboard = [UIStoryboard storyboardWithName:@"Main_iPhone"                                                             bundle: nil];
       Nearbylocations *introViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"near"];
       self.window.rootViewController=introViewController;