如何通过TabBarController => NavbarController从Appdelegate呈现视图控制器

问题描述 投票:0回答:3

我如何使用appdelegate的所有堆栈呈现视图控制器。 TabBarContoller是rootviewcontoller。 我在TabBarController上有4个标签,每个标签都是导航控制器。 所以我需要像这样呈现viewcontroller。 tabBar => navBar => mainViewContoller => aViewController => bViewController; 我应该可以用来导航回mainviewcontroller或通过tabbar导航。

我有一个故事板。

我尝试了很多类似问题推荐的解决方案,但没有帮助。

objective-c uinavigationcontroller uitabbarcontroller appdelegate presentviewcontroller
3个回答
0
投票

您应该只通过故事板实现这一点。

我尝试使用appcoda进行示例项目。我成功运行它。我向您展示了故事板设计。

enter image description here

enter image description here

它已使用多个视图控制器实现。


0
投票
TabBarController * tabBar = (TabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController;
                   if([tabBar isKindOfClass:[UITabBarController class]]){
                   [tabBar setSelectedIndex:0];
                   UINavigationController * navBar = (UINavigationController *)tabBar.selectedViewController;
                   UIViewController * currentVC = navBar.topViewController;
                   [currentVC performSegueWithIdentifier:@"notificationSegue" sender:nil];

0
投票

我认为这可能对你所有的人都很有帮助。我有类似的项目设置,LoginViewcontroller - > TabBarController(5个选项卡) - >每个选项卡的NavigationController - >其他ViewControllers

在storyboard中,我为我的TabBarController提供了一个故事板ID

在AppDelegate(didFinishLaunchingWithOptions)中我添加了

self.window = UIWindow(frame: UIScreen.main.bounds)
let storyboard = UIStoryboard.init(name: "Main", bundle: nil)
let viewController = storyboard.instantiateViewController(withIdentifier: "TabBarControllerID") as! UITabBarController
viewController.selectedIndex = 3
self.window?.rootViewController = viewController
self.window?.makeKeyAndVisible()

将selectedIndex值更改为您需要的任何选项卡

© www.soinside.com 2019 - 2024. All rights reserved.