Question

I am using to change tabs (rootView) programatically by using this code:

NSInteger tabitem = tabBarController.selectedIndex;
[[tabBarController.viewControllers objectAtIndex:tabitem] popToRootViewControllerAnimated:YES];

But when I want to use a button to change the tab from a view, I cannot display the rootView. I am using this code but it does not show the rootView:

self.tabBarController.selectedIndex = 3;
Was it helpful?

Solution

This is the solution:

https://stackoverflow.com/a/12681125/3507283

int index = 3;
self.tabBarController.selectedIndex = index;
[self.tabBarController.viewControllers[index] popToRootViewControllerAnimated:NO];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top