简体   繁体   English

无法从AppDelegate推送到View Controller而不会丢失导航栏和标签栏设置iOS

[英]Can't push to View Controller from AppDelegate without losing Navigation Bar and Tab Bar setup iOS

I try to push to specific view controller from app delegate without losing previously set navigation bar and tab bar items setup. 我尝试从app delegate推送到特定的视图控制器,而不会丢失先前设置的导航栏和标签栏项目设置。

As presented in my Main storyboard: 如我的主故事板中所示:

故事板

After 1 action performed in TypeNameVC, on app relaunch I want to skip LogInVC and TypeNameVC in didFinishLaunchingWithOptions in AppDelegate forward to MapViewController or any other VC of Tab Bar Controller. 在TypeNameVC中执行1次操作后,在应用程序重新启动时,我想跳过AppDelegate中didFinishLaunchingWithOptions中的LogInVC和TypeNameVC转发到MapViewController或任何其他标签栏控制器的VC。

This code initializes new Navigation Controller with new Navigation Bar and Tab Bar Controller is missing. 此代码使用新的导航栏初始化新的导航控制器,并且缺少标签栏控制器。

UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
//To instantiate Main.storyboard.
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
//To instantiate VC to go to.
MapViewController *mapVC = (MapViewController *)[storyboard instantiateViewControllerWithIdentifier:@"MapViewControllerID"];
//To push to instantiated VC.
[navigationController pushViewController:mapVC animated:YES];

I tried to performSegue using segue to Tab Bar Controller but on Navigation Controller stack there is only LoginViewController (I checked it with [navigationController viewControllers] ) 我试图performSegue使用SEGUE到标签栏控制器,但在导航控制器栈只有LoginViewController(我检查了它[navigationController viewControllers]

I read through entire Stack Overflow, I made dozens of combinations but I can't figure out the solution. 我阅读了整个Stack Overflow,我做了几十个组合,但我无法弄清楚解决方案。 I would appreciate any help/advice. 我将不胜感激任何帮助/建议。

UPDATED QUESTION Screen: screen 更新的问题屏幕: 屏幕

Have a look to the screen image. 看看屏幕图像。 First row of screen shows how it looks like if I navigate "normally". 第一行屏幕显示了如果我“正常”导航它的样子。 Second row shows what happens if I push to MapVC from AppDelegate. 第二行显示如果我从AppDelegate推送到MapVC会发生什么。 What I need is to skip first two VC's with maintaining Navigation and Tab Bar bars setup. 我需要的是在保持导航和标签栏设置的情况下跳过前两个VC。

When I navigate "normally" Tab Bar Controller and it's VC's get correctly allocated. 当我导航“正常”标签栏控制器并且它的VC被正确分配。

2016-06-08 12:37:44.394 Checkpoint[4196:1034786] Navigation Controller VC's: ( LogInViewController: 0x135d50b00, 2016-06-08 12:37:44.394 Checkpoint [4196:1034786]导航控制器VC的:(LogInViewController:0x135d50b00,
TypeNameViewController: 0x135f455b0, TypeNameViewController:0x135f455b0,
UITabBarController: 0x135f1d180 UITabBarController:0x135f1d180
)
2016-06-08 12:37:44.394 Checkpoint[4196:1034786] Tab Bar Controller VC's: ( 2016-06-08 12:37:44.394 Checkpoint [4196:1034786] Tab Bar Controller VC :(
MapViewController: 0x137078cf0, MapViewController:0x137078cf0,
PlacesTableViewController: 0x135f1d7d0, PlacesTableViewController:0x135f1d7d0,
FriendsTableViewController: 0x137083350 FriendsTableViewController:0x137083350
)

When I push directly to MapVC they don't. 当我直接推送到MapVC时,他们没有。 I do get the point what's going on but I know how to code that solution. 我确实知道发生了什么,但我知道如何编写该解决方案。

Navigation Controller VC's: ( 导航控制器VC :(
LogInViewController: 0x15fd5ccf0, LogInViewController:0x15fd5ccf0,
MapViewController: 0x15fd6ffa0 MapViewController:0x15fd6ffa0
)
2016-06-08 12:31:53.813 Checkpoint[4187:1033755] Tab Bar Controller VC's: (null) 2016-06-08 12:31:53.813 Checkpoint [4187:1033755] Tab Bar Controller VC :( null)

Customize your class MapViewController for visible Navigation Bar and Tab Bar : 为可见的导航栏标签栏自定义MapViewController类:

- (instancetype)init
{
    // init code        
    self.hidesBottomBarWhenPushed = NO;
    retur self;
}

-(void)viewWillAppear:(BOOL)animated
{
    // some code
    [self.navigationController setNavigationBarHidden:NO];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从AppDelegate和Tab Bar推送View Controller - Push View Controller From AppDelegate and Tab Bar 如何将视图控制器推送到iOS中标签栏中的导航控制器 - how to push a view controller to a navigation controller in a tab bar in iOS iOS Push Navigation Controller,第二个视图上没有栏 - iOS Push Navigation Controller, without a bar on the second view 推送/弹出视图控制器,带有导航栏,来自View Controller,不带导航栏 - Push / Pop View Controller With Navigation Bar from View Controller Without Navigation Bar AppDelegate中的iOS初始化选项卡栏控制器视图控制器 - iOS Init Tab Bar Controller View Controllers in AppDelegate iOS导航栏,无控制器推送 - iOS navigation bar with push without controller 从导航栏视图控制器导航到选项卡栏视图控制器 - Navigate from a navigation bar view controller to a tab bar view controller 在标签栏中推送View Controller - Push view Controller in the tab bar 如何在不失去导航栏访问权限的情况下更改视图控制器中辅助功能元素的顺序? - How can I change the order of accessibility elements in a view controller without losing access to the navigation bar? 从 AppDelegate 加载标签栏控制器 - Load Tab Bar Controller from AppDelegate
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM