I have the following scenario. A view controller that's embedded in a navigation controller.
This view controller has a button that instantiate a tab bar controller, then presents one of its view controllers.
When i dismiss the controller presented by the tab bar controller, i always end up in the initial view controller, in the same instance of it.
What i tried is:
func showHomeScreen() {
//trying to dismiss the current view controller ( will move this code out of this method once i figure out how to do it
self.navigationController?.popViewController(animated: true)
self.dismiss(animated: true, completion: nil)
//showing the next view controller
let tabBarController = storyboard?.instantiateViewController(withIdentifier: "TabBarController") as! TabBarController
tabBarController.selectedViewController = tabBarController.viewControllers?[1]
present(tabBarController, animated: true, completion: nil)
}
self.navigationController?.popViewController
=> returns nil
self.dismiss(animated: true, completion: nil)
doesn't seem to do anything.
Can anyone please tell me how to fix this, i imagine its something terribly simple but i can't find the answer to it.
Edit: This is how my storyboard looks:
https://pasteboard.co/HVdHp6P.png
https://pasteboard.co/HVdHHoG.png