1

我想从我的应用程序中的功能中弹出我ViewController的功能,我为此添加了代码,但仅在我的第一个 .not 中弹出。TabBarViewControllerLogouttabbarViewController

4

3 回答 3

1

假设您具有以下结构

窗口 - UINavigationController - (LoginViewController) - UITabBarController - (VC,VC)

这会起作用

AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
UINavigationController *navController = (UINavigationController *)appDelegate.window.rootViewController;
[navController popToRootViewControllerAnimated:YES];
于 2013-06-01T09:35:49.637 回答
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];
于 2013-06-01T06:07:00.833 回答
0

您可以[self.navigationController popToRootViewControllerAnimated:YES];用于将 viewController 弹出到根 viewController

于 2013-06-01T06:07:02.000 回答