gpt4 book ai didi

iphone - 如何将 TabBarViewController 与 NavigationController 一起使用

转载 作者:行者123 更新时间:2023-11-28 20:46:00 26 4
gpt4 key购买 nike

我知道我可以做到这一点

 [self.navigationController pushViewController:self.someUITabBarController animated:YES];

这意味着以某种方式将 UITabBarController 放在 navigationgController

如果我想让 someUITabBarController 成为 navigationController 的第一个 Controller (位于最低级别的那个)怎么办?

我根本无法将 NavigationControllerrootViewController 更改为 someUITabBarController

最佳答案

嗯,不确定这是你想要的。下面这段代码将放在 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 下,在您的“appDelegate”类中。

UITabBarController *tabController = [[UITabBarController alloc] init];
UIViewController *viewController1 = ...
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController1];

NSArray *controllers = [NSArray arrayWithObjects:navigationController, nil]; // can add more if you want

[tabController setViewControllers:controllers];

// this is for custom title and image in the tabBar item
navigationController.tabBarItem.title = @"abc";
[navigationController.tabBarItem setImage:[UIImage imageNamed:@"abc.png"]];

self.window.rootViewController = tabController; // or [self.window addSubview: tabController.view];
[self.window makeKeyAndVisible];

关于iphone - 如何将 TabBarViewController 与 NavigationController 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6366175/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com