在应用程序中有一个 UITabBar 和一个 UINavigationController? [英] Having a UITabBar AND a UINavigationController in an app?

查看:16
本文介绍了在应用程序中有一个 UITabBar 和一个 UINavigationController?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我是 iPhone 开发的新手,我不了解整个 UINavigationController 和 UITabBarController 的想法.一个可以替代另一个 - Tweetie 等应用如何将两者结合起来?

Hey everyone, I am new to iPhone development and I'm not understanding the whole UINavigationController and UITabBarController idea. Is one a substitute for the other - how do apps such as Tweetie combine both?

我想让我的应用程序在底部有一个持久的标签栏(这似乎正在工作),但在顶部还有一个导航栏,可以在不移除标签栏的情况下将视图推送/弹出到屏幕上.

I'd like to have my app have a persistent Tab Bar @ the bottom (which seems to be working), but also a Navigation bar at the top which can push/pop views onto the screen without removing the tab bar.

  • 我怎样才能做到这一点?
  • 就所有这些控制器而言,就我的 MainWindow.xib 而言,IB 中的层次结构应该是什么样的?
  • 这里的最佳做法是什么?

非常感谢,

推荐答案

只需将视图控制器包装在 UINavigationController 中,并将 UINavigationController 放入 UITabBar.这对你来说很好......

Just wrap the view controller inside the UINavigationController and Place the UINavigationController inside the UITabBar. This will work fine for you…

例子:

NSMutableArray *tabBarViewControllers = [[NSMutableArray alloc] initWithCapacity:2];

tabBarController = [[UITabBarController alloc] init];
[tabBarController setDelegate:self];

UINavigationController *navigationController = nil;
navigationController = [[UINavigationController alloc] initWithRootViewController:<Your View controller1>];
[tabBarViewControllers addObject:navigationController];
[navigationController release];
navigationController = nil;

navigationController = [[UINavigationController alloc] initWithRootViewController:<Your View controller2>];
[tabBarViewControllers addObject:navigationController];
[navigationController release];
navigationController = nil;

tabBarController = tabBarViewControllers;
[tabBarViewControllers release];
tabBarViewControllers = nil;

这篇关于在应用程序中有一个 UITabBar 和一个 UINavigationController?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆