我想从TabBar
弹出ViewController
,该TabBar
是从我的应用程序中的ViewController
for Logout
功能推入的,我为此放了代码,但只在tabbar
弹出,而不是在我的第一个ViewController
。
Try this code in your logout button action method
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];
Assuming you have following structure
Window - UINavigationController - (LoginViewController) - UITabBarController - (VC,VC)
This would work
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication]delegate];
UINavigationController *navController = (UINavigationController *)appDelegate.window.rootViewController;
[navController popToRootViewControllerAnimated:YES];
You can use [self.navigationController popToRootViewControllerAnimated:YES];
for popping the viewController into root viewController
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.