It seems that didSelectViewController
is triggered before the tab controller has switched to the destination tab.
Therefore the execution of the method popToRootViewControllerAnimated
correctly pops all the view controllers, but can't really release the visible one, as it is currently being depicted by the app.
To achieve my result, I've figured out the following solution.
In the viewDidAppear
method of all the view controllers which correspond to the first view controller for each tab, I execute popToRootViewControllerAnimated
(all of them are navigation controller).