我想从ViewController
中弹出TabBar
ViewController
,该Logout
是从tabbar
推送到我的应用程序中的ViewController
功能,我为此设置代码,但只会弹出{{1}}。不在我的第一个{{1}}。
答案 0 :(得分:1)
在您的退出按钮操作方法
中尝试此代码AppDelegate *appdelegate = (AppDelegate*)[[UIApplication sharedApplication]delegate];
LoginVC *viewController = [[LoginVC alloc]initWithNibName:@"LoginVC" bundle:nil];
NSArray *array = @[viewController];
[appdelegate.navController setViewControllers:array];
[appdelegate.tabbarController.view removeFromSuperview];
[[appdelegate tabbarController] removeFromParentViewController];
NSLog(@"array - > %@",array);
[appdelegate.window setRootViewController:appdelegate.navController];
答案 1 :(得分:1)
假设您有以下结构
Window - UINavigationController - (LoginViewController) - UITabBarController - (VC,VC)
这样可行
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
UINavigationController *navController = (UINavigationController *)appDelegate.window.rootViewController;
[navController popToRootViewControllerAnimated:YES];
答案 2 :(得分:0)
您可以使用[self.navigationController popToRootViewControllerAnimated:YES];
将viewController弹出到root viewController