Badr Filali
Badr Filali

Reputation: 300

Dismiss two NavigationController in same time

My storyboard

I want to come back from the last page to the first one with popToRootController when I click on the grey button at the bottom of the page.

I don't understand how I can act on both Navigation controller in the sameTime. I use a lib for the two last page. SideMenu Lib

All I could do actually is to dismiss the last Navigation controller and land on the blue page, and it's not what I need.

Upvotes: 1

Views: 263

Answers (1)

Shehata Gamal
Shehata Gamal

Reputation: 100543

You can try

self.navigationController?.navigationController?.popToRootViewController(animated:true)

OR

if it's the root

let vc = //

let nav = // set vc as root

UIApplication.shared.keyWindow?.rootviewController = nav

//

OR

if let root = UIApplication.shared.keyWindow?.rootviewController as? UINavigationController {

    root.popToRootViewController(animated:true)

 }

Upvotes: 3

Related Questions