按钮从另一个视图转到rootview
-
02-01-2020 - |
题
我正在使用此代码以编程方式更改选项卡(rootview):
NSInteger tabitem = tabBarController.selectedIndex;
[[tabBarController.viewControllers objectAtIndex:tabitem] popToRootViewControllerAnimated:YES];
.
但是当我想使用一个按钮从视图中更改选项卡时,我无法显示rootview。我正在使用这个代码,但它没有显示rootview:
self.tabBarController.selectedIndex = 3;
. 解决方案
这是解决方案:
https://stackoverflow.com/a/12681125/3507283
int index = 3;
self.tabBarController.selectedIndex = index;
[self.tabBarController.viewControllers[index] popToRootViewControllerAnimated:NO];
. 不隶属于 StackOverflow