How to return to Root View Controller

15,060

Solution 1

You need to dismiss presented model then you can pop all the pushed view controllers. As presented model would not be in the stack of the navigation.

self.dismissViewControllerAnimated(true, completion: {});

Then you can pop to base view controller.

self.navigationController.popViewControllerAnimated(true);

Solution 2

If you use presentViewController, you can use

[self.view.window.rootViewController dismissViewControllerAnimated:YES completion:nil];

to go back to root view. It works on IOS9.

Solution 3

Swift 4

self.dismiss(animated: true, completion: {});
self.navigationController?.popViewController(animated: true);
Share:
15,060
TheRealRonDez
Author by

TheRealRonDez

Computer Science Major. Currently in Graduate School.

Updated on June 06, 2022

Comments

  • TheRealRonDez
    TheRealRonDez almost 2 years

    I am currently working on an app which presents a screen modally and another custom progress indicator modally. Is it possible to return to the root View Controller seamlessly?

    Home -> screen1-> screen2(Custom progressIndicator)

    I want to dismiss the custom progressIndicator (and the screen presented modally) and return to my home (root) View Controller in one go.

     self.navigationController?.popToRootViewControllerAnimated(true)
    

    Thank you for the help!