大家好,我是 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.
非常感谢,
只需将视图控制器包装在 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!