I have a tabBar controller as parent and I'm pushing a view controller with navigationController. then presenting 2 other view Controllers above to it. its like Tabbar(homeController) -> Child1(push) -> Child 2(presenting) -> child3(presenting). and im dismiss my last childViewController using timer. when its dismissing I want to go back to tabBarController(home).
let parent = self.presentingViewController
self.dismiss(animated: false, completion: {
parent?.present(vc, animated: true, completion: nil)
})
I put this above code in my 2nd Child ViewController. But its come back to child1 viewContoller. need some help here.
If you are using a storyboard then first setup an unwind segue on the view controller you want to return to (so that tabBarController in this case) like this:
@IBAction func unwindToTop(segue:UIStoryboardSegue) { }
(you can call it what you want as long as you start it 'unwindTo')
Then in interface builder create an unwind segue (either direct from an object like a button or more generic from the view controller itself) to the exit of the view controller and select the unwind segue that should appear in the list.
Then when this segue is performed, either through a storyboard item or manually in code, you will be returned to the view controller that defined the unwind segue. The system will do all the back traversal for you.