Member-only story

UINavigationController : pop and push view controller iOS

Mr.Javed Multani
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];

--

--

Mr.Javed Multani
Mr.Javed Multani

Written by Mr.Javed Multani

Software Engineer | Certified ScrumMaster® (CSM) | UX Researcher | Youtuber | Tech Writer

No responses yet