在应用程序中有UITabBar和UINavigationController?

bar*_*oon 7 iphone uitabbarcontroller uinavigationcontroller iphone-sdk-3.0

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

我希望我的应用程序在底部有一个持久的Tab Bar(看起来很有效),但顶部还有一个导航栏,可以在不删除标签栏的情况下将视图推送/弹出到屏幕上.

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

非常感谢,

Man*_*ath 15

只需将视图控制器包裹在内部UINavigationController并放置在UINavigationController内部UITabBar.这对你来说很好......

例:

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;
Run Code Online (Sandbox Code Playgroud)