来自UITabBarController的Pop UIViewController

时间:2013-06-01 05:34:40

标签: iphone ios uiviewcontroller uitabbarcontroller

我想从ViewController中弹出TabBar ViewController,该Logout是从tabbar推送到我的应用程序中的ViewController功能,我为此设置代码,但只会弹出{{1}}。不在我的第一个{{1}}。

3 个答案:

答案 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