在 iPhone 中推送 tabbarcontroller / 在 iPhone 应用程序中推送多个 tabbarcontroller

发布于 2024-11-07 16:34:21 字数 93 浏览 0 评论 0原文

我创建了一个基于选项卡栏的项目,我的第一个选项卡有一个导航控制器。在我的导航控制器中(推送 2 个视图后)我想添加/推送另一个选项卡控制器。所以请有人建议我如何做到这一点。

I have created a tabbar based project and my first tab have a navigation controller. and in my navigation controller (after push 2 views) i want to add/push one other tabbarcontroller. so please can any one suggest how i do this.

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

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

发布评论

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

评论(1

蓝海似她心 2024-11-14 16:34:21

更新:再次阅读您的文章后,我想我误解了它! UINavigationControllers 内部不能有 UITabBarController,它只能以相反的方式工作!

如果你真的想这样做(真的想一想!!),你可以编写自己的 UITabBarController 实现,它在 UINavigationController 中很满意(Twitter for iPhone 使用这样一个自定义编写的 UITabBarController)

链接: UITabBarController内部UINavigationController


只是将包含 UIView 的 NSArray 提供给 tabbarcontrollers viewControllers 属性。
tabcontroller =[[UITabBarController alloc] init];

UINavigationController *navcon = [[UINavigationController alloc] init];
UINavigationController *navcon2 = [[UINavigationController alloc] init];
UINavigationController *navcon3 = [[UINavigationController alloc] init];
[navcon pushViewController:someuiview animated:NO];
[navcon2 pushViewController:someuiview2 animated:NO];
[navcon3 pushViewController:someuiview3 animated:NO];

[someuiview release];[someuiview2 release];[someuiview3 release];

tabcontroller.viewControllers=[NSArray arrayWithObjects:navcon, navcon2, navcon3, nil];
[navcon release]; [navcon2 release]; [navcon3 release];

someuiviewn 是 UIViewControllers 的子类(例如 UITableViewControllers(或者其他什么:))

UPDATE: After reading your post once more I think I misunderstood it! UINavigationControllers can't have a UITabBarController inside them, it only works the other way round!

If you really want to do this (really think about it!!) you could write your own implementation of a UITabBarController that is happy inside of a UINavigationController (Twitter for iPhone uses such a custom written UITabBarController)

Link: UITabBarController insider UINavigationController


Just feed the tabbarcontrollers viewControllers property with an NSArray containing your UIViews.
tabcontroller =[[UITabBarController alloc] init];

UINavigationController *navcon = [[UINavigationController alloc] init];
UINavigationController *navcon2 = [[UINavigationController alloc] init];
UINavigationController *navcon3 = [[UINavigationController alloc] init];
[navcon pushViewController:someuiview animated:NO];
[navcon2 pushViewController:someuiview2 animated:NO];
[navcon3 pushViewController:someuiview3 animated:NO];

[someuiview release];[someuiview2 release];[someuiview3 release];

tabcontroller.viewControllers=[NSArray arrayWithObjects:navcon, navcon2, navcon3, nil];
[navcon release]; [navcon2 release]; [navcon3 release];

someuiviewn are subclasses of UIViewControllers (maybe UITableViewControllers for example (or whatever :))

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