gpt4 book ai didi

ios - 如何将 TabbarController 添加到 NavigationController

转载 作者:行者123 更新时间:2023-11-29 02:30:57 25 4
gpt4 key购买 nike

我有一个带有 navigationController 和 Storyboard 的项目。现在我需要添加另一个项目(合并两个项目)我想使用 TabbarController 在两个导航 Controller 之间切换。我怎样才能意识到这一点?

最佳答案

将此代码放入您的 AppDelegates View Controller 中:-

 @implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

UITabBarController *tabBar = [[UITabBarController alloc] init];

ViewController *homeVC = [[ViewController alloc] init];
homeVC.tabBarItem.title = @"Home";
homeVC.tabBarItem.image = [UIImage imageNamed:@"Home-icon.png"];
UINavigationController *HomeNavi = [[UINavigationController alloc] initWithRootViewController:homeVC];

settingViewController *settingVC = [[settingViewController alloc] init];
settingVC.tabBarItem.title = @"Setting";
settingVC.tabBarItem.image = [UIImage imageNamed:@"Setting-icon.png"];
UINavigationController *settingNavi = [[UINavigationController alloc] initWithRootViewController:settingVC];

tabBar.viewControllers = [NSArray arrayWithObjects:HomeNavi,settingNavi, nil];
HomeNavi.navigationBarHidden = YES;
settingNavi.navigationBarHidden = YES;
[self.window makeKeyAndVisible];
self.window.rootViewController = tabBar;
// Override point for customization after application launch.
return YES;
}

关于ios - 如何将 TabbarController 添加到 NavigationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26884163/

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