如何在现有的 iPhone 应用程序中用选项卡栏控制器替换导航根控制器

发布于 2024-10-20 09:25:21 字数 75 浏览 1 评论 0原文

我有一个现有的 iPhone 应用程序,其中导航控制器作为其根控制器。现在我必须在屏幕底部添加一个标签栏控制器。我怎样才能实现这个改变?

I have an existing iphone app whihc has nav controller as its root controller. Now i have to add a tab bar controller at the bottom of the screen. how can i achieve this change?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只有影子陪我不离不弃 2024-10-27 09:25:21

首先你需要在根目录中创建标签栏控制器,然后为每个标签栏放置导航控制器或其他视图控制器

祝你好运

first you need to create tab bar controller in the root , then you put navigation controller or other view controller for each tab bar

good luck

ペ泪落弦音 2024-10-27 09:25:21

您是否有多个视图控制器要显示在选项卡中?
将 viewController 添加到 tabBar 的 viewController 中。使用此属性,

tabBarController.viewControllers = view_Controllers_Array;

例如。

NSMutableArray * viewControllers = [[NSMutableArray alloc]init];


FirstViewController * firstViewController = [[FirstViewController alloc]initWithNibName:@"FirstViewController" bundle:nil];
UINavigationController * nvc = [[UINavigationController alloc] initWithRootViewController:firstViewController];
[firstViewController release];
[viewControllers addObject:nvc];
[nvc release];

SecondViewController * secondViewController = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
 nvc = [[UINavigationController alloc] initWithRootViewController:secondViewController];
[secondViewController release];
[viewControllers addObject:nvc];
[nvc release];

UITabBarController * tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = viewControllers;
[window addSubview:tabBarController.view];

Are you having more than one viewControllers to be shown in the tab?
Add the viewControllers to tabBar's viewControllers. USe this property

tabBarController.viewControllers = view_Controllers_Array;

eg.

NSMutableArray * viewControllers = [[NSMutableArray alloc]init];


FirstViewController * firstViewController = [[FirstViewController alloc]initWithNibName:@"FirstViewController" bundle:nil];
UINavigationController * nvc = [[UINavigationController alloc] initWithRootViewController:firstViewController];
[firstViewController release];
[viewControllers addObject:nvc];
[nvc release];

SecondViewController * secondViewController = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
 nvc = [[UINavigationController alloc] initWithRootViewController:secondViewController];
[secondViewController release];
[viewControllers addObject:nvc];
[nvc release];

UITabBarController * tabBarController = [[UITabBarController alloc] init];
tabBarController.viewControllers = viewControllers;
[window addSubview:tabBarController.view];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文