NavigationController 内的 TabBarController

发布于 2024-12-10 13:46:19 字数 321 浏览 0 评论 0原文

想象一下,我们有由导航控制器控制的多视图应用程序。我们使用pushViewController方法从第一个视图转到第二个视图,这不是问题,但我们需要移动到第三个视图。第三个是一个看起来像 TabBar 的视图。我们该怎么做呢?第三个视图应该由 TabBarController 控制,不是吗? 那么如何传递控制呢?我声明了一个插座 UITabBarController * tbc 并将其连接到 xib 文件中的 TabBarController ,然后我在 viewDidLoad 中尝试了此操作: tbc = [[UITabBarController 分配]init];

它什么也没显示。 非常感谢您的帮助

Imagine that we have multiview apllication which is controlled by Navigation Controller. We go from the first view to second by using pushViewController method and that's not a problem but then we need to move to the third view. And the third one is a view which looks like a TabBar. How do we do that? The third view is supposed to be controlled by TabBarController, isn't it?
So how to pass the control? I declared an outlet UITabBarController * tbc and connected it to TabBarController in xib file and then i tried this in viewDidLoad:
tbc = [[UITabBarController alloc]init];

and it shows nothing.
Your help is highly appreciated

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

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

发布评论

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

评论(2

阪姬 2024-12-17 13:46:19

这有点奇怪。更标准的是有一个 tabBarController 来切换视图,其中一些视图可能是导航控制器。但是...

创建 UITabBarController 并推送它。

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

// create someView
[viewControllers addObject:someView];
// create someView2
[viewControllers addObject:someView2];


UITabBarController *tabController = [[UITabBarController alloc] init];
[tabController setViewControllers:viewControllers];

[[self navigationController] pushViewController:tabController animated:YES];

然后,从 tabBarContoller 视图中,基于某些操作,您可以选择弹出它:

[self.navigationController popViewControllerAnimated: NO];

It's a bit wierd. Its more standard to have a tabBarController that switches views and some of those views may be navigation controllers. But ...

Create the UITabBarController and push it.

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

// create someView
[viewControllers addObject:someView];
// create someView2
[viewControllers addObject:someView2];


UITabBarController *tabController = [[UITabBarController alloc] init];
[tabController setViewControllers:viewControllers];

[[self navigationController] pushViewController:tabController animated:YES];

Then, from the tabBarContoller view, based on some action, you can choose to pop it:

[self.navigationController popViewControllerAnimated: NO];
兔小萌 2024-12-17 13:46:19

您可以在最新版本的 Xcode 的故事板编辑器中将其连接起来。

然而,由于这在很大程度上是非标准的控件使用,因此您需要一个非常充分的理由来解释为什么需要这样的 UI。

即便如此,如果界面笨拙,苹果的审核流程也可能会拒绝你的应用程序。

You can wire it up in the storyboard editor in the latest version of Xcode.

However, since this is very much non-standard use of the controls, you would need a very good reason as to why you would want a UI like this.

And even then, Apple's review process might turn your app down if the interface is clunky.

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