Programmatically switch to another tab AND switch to the first view controller?

后端 未结 3 1154
无人共我
无人共我 2020-12-22 12:28

How do I programmatically switch to another tab and go to the first view in the navigation stack ?

I can switch to a different tab.

self.tabBarContro         


        
3条回答
  •  情话喂你
    2020-12-22 13:13

    I assume you have UINavigationControllers in your UITabBarController. If that's the case you can use popToRootViewControllerAnimated: to go to the first view controller.

    int index = 4;
    self.tabBarController.selectedIndex = index;
    [self.tabBarController.viewControllers[index] popToRootViewControllerAnimated:NO];
    

提交回复
热议问题