ios-从appdelegate推送后,标签栏丢失

时间:2018-09-02 22:15:52

标签: objective-c iphone uitabbarcontroller appdelegate

嗨,我有一个类似this的项目结构 我想注销后回到首页(RootView)。

“在推送时隐藏底部栏”未选中。

我尝试使用此代码,但是缺少“主页”标签栏:

   AppDelegate *appDelegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
UIStoryboard *homeStoryboard = [UIStoryboard storyboardWithName:@"Home" bundle:[NSBundle mainBundle]];

HomeViewController *homeViewController = [authenticationStoryboard instantiateInitialViewController];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:homeViewController];
HomeViewController *rootViewController = [authenticationStoryboard instantiateViewControllerWithIdentifier:NSStringFromClass([HomeViewController class])];

[navigationController pushViewController:rootViewController animated:true];

appDelegate.window.rootViewController = navigationController;

尝试使用此代码但显示错误(“应用程序试图在其自身上显示模式视图控制器”)

AppDelegate *appDelegate = (AppDelegate *) [UIApplication sharedApplication].delegate;
UITabBarController* rootController = [[UIStoryboard storyboardWithName:@"Home" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"HomeViewController"];
appDelegate.window.rootViewController = rootController;
[UIApplication.sharedApplication.keyWindow.rootViewController presentViewController:navigation animated:true completion:nil];

请告诉我如何解决。谢谢。

0 个答案:

没有答案