Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to return to Root View Controller

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!

like image 818
Ronaldoh1 Avatar asked Dec 17 '15 04:12

Ronaldoh1


People also ask

How do I get root view controller?

The root view controller is simply the view controller that sits at the bottom of the navigation stack. You can access the navigation controller's array of view controllers through its viewControllers property. To access the root view controller, we ask for the first item of the array of view controllers.

What is root view controller in Swift?

The root view controller provides the content view of the window. Assigning a view controller to this property (either programmatically or using Interface Builder) installs the view controller's view as the content view of the window.


1 Answers

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);
like image 150
Pankaj Teckchandani Avatar answered Sep 22 '22 08:09

Pankaj Teckchandani