Member-only story
UINavigationController : pop and push view controller iOS
1 min readOct 3, 2020
Popping in a Navigation Controller
To previous view controller
To pop back to the previous page you can do this: Swift
navigationController?.popViewControllerAnimated(true)
Objective C
[self.navigationController popViewControllerAnimated:YES];
To root view controller
To pop to the root of the navigation stack, you can do this: Swift
navigationController?.popToRootViewControllerAnimated(true)
Objective C
[self.navigationController popToRootViewControllerAnimated:YES];
Pushing a view controller onto the navigation stack
Swift
let fooViewController = UIViewController()
navigationController?.pushViewController(fooViewController, animated: true)
Objective C
UIViewController *fooViewController = [[UIViewController alloc] init];
[navigationController pushViewController:fooViewController animated:YES];