For programmatic navigation using the Navigation Controller methods below, you must be using a NavigationController. You can start a navigation stack by building a NavigationController and setting the RootViewController as the first UIViewController you wish to display.

RoomsViewController *roomsViewController = [[RoomsViewController alloc] init];

UINavigationController *roomsNavController = [[UINavigationController alloc] initWithRootViewController:roomsViewController];

The navigationController property will then be populated inside your UIViewController.


Push a new item onto the navigation stack by calling pushViewController

[self.navigationController pushViewController:someOtherViewController animated:true];


Pop an item off the navigation stack by calling one of three methods.

[self.navigationController popViewControllerAnimated:true];

[self.navigationController popToRootViewControllerAnimated:true];

[self.navigationController popToViewController:someOtherViewController animated:true]];

popViewControllerAnimated will pop the current UIViewController of the stack and display the next in the stack.

popToRootViewControllerAnimated will pop back to the root UIViewController for the current natviation stack.

popToViewController pops until the specified UIViewController is at the top of the stack.

Modal Display

Modal display doesn't require the use of the navigationController property and instead relies on methods built into UIViewController.


To show a UIViewController as a modal use the presentViewController method.

[self presentViewController:homeController animated:true completion:nil];


To close a Modal display use the dismissViewControllerAnimated method.

[self dismissViewControllerAnimated:true completion:nil];