问题描述
大家好,我是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?
我想让我的应用程序在底部有一个持久的Tab Bar(似乎工作正常),但顶部的导航栏可以在不移除标签栏的情况下将视图推送/弹出到屏幕上。
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.
- 我怎样才能做到这一点?
- 对于所有这些控制器,IB的层次结构在我的MainWindow.xib中应该是什么样的?
- 这里的最佳做法是什么?
非常感谢,
推荐答案
将视图控制器包装在 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!