Francesco Gregori
Francesco Gregori

Reputation: 7

Go back to tab bar controller with index 2

this is my procedural scheme i have a tab controllore with 3 items and into 1 items i have a navigation controller than into this i have a popup

i need to go back from my popup to my tab bar controller with index 2

this is my code but doesn't work.

let TabViewController = self.storyboard?.instantiateViewController(withIdentifier: "TabViewController") as! TabViewController
    self.present(TabViewController, animated: true)

I have to be able to go back from my popup, to my tab bar controller directly to the page with item 2

Upvotes: 0

Views: 1196

Answers (1)

Shehata Gamal
Shehata Gamal

Reputation: 100503

You can try

self.dismiss(animated:true) {
     let TabViewController = self.storyboard?.instantiateViewController(withIdentifier: "TabViewController") as! TabViewController
     TabViewController.selectedIndex = 2
     UIApplication.shared.keyWindow?.rootViewController = TabViewController 
}

Upvotes: 1

Related Questions