我有一个带有包含三个选项卡的 Tabbar 控制器的应用程序。我需要将导航控制器添加到第一个选项卡。我的根视图控制器是标签栏,那么如何添加导航栏?我已经初始化导航栏,但不知道在哪里设置它。感谢任何可以提供帮助并询问您是否需要更多信息的人。这是我的应用程序 delegate.m:
#import "TACAppDelegate.h"
#import "FirstViewController.h"
#import "ThirdViewController.h"
#import "SecondViewController.h"
@implementation TACAppDelegate
@synthesize window = _window;
@synthesize tabBarController = _tabBarController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
/* Initialize window view */
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
/* Initialize tab bar controller, add tabs controllers */
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [self initializeTabBarItems];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
return (YES);
}
....
- (NSArray *)initializeTabBarItems
{
NSArray * retval;
/* Initialize view controllers */
FirstViewController *viewController1 = [[FirstViewController alloc] init];
SecondViewController *viewController2 = [[SecondViewController alloc] init];
ThirdViewController *viewController3 = [[ThirdViewController alloc] init];
/* Initialize navigation controllers */
UINavigationController *navigationController1 = [[UINavigationController alloc] initWithRootViewController:viewController1];
/* Stuff Navigation Controllers into return value */
retval = [NSArray arrayWithObjects:viewController1,viewController2,viewController3,nil];
return (retval);
}
@end