点击按钮时从另一个视图转到rootView

时间:2014-08-01 17:26:57

标签: ios7 uitabbarcontroller rootview

我正在使用以下代码以编程方式更改标签(rootView):

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

但是当我想使用按钮从视图中更改选项卡时,我无法显示rootView。我正在使用此代码,但它没有显示rootView:

self.tabBarController.selectedIndex = 3;

1 个答案:

答案 0 :(得分:0)

这是解决方案:

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

int index = 3;
self.tabBarController.selectedIndex = index;
[self.tabBarController.viewControllers[index] popToRootViewControllerAnimated:NO];
相关问题