Go to rootView from another view when a button tapped
-
02-01-2020 - |
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;
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