UINavigationController与UITabBarController

本文介绍了一个iOS应用中使用五个不同的UINavigationController实例配合UITabBarController实现底部标签栏导航的初始化过程。具体包括了如何创建并配置每个导航控制器及其对应的根视图控制器,并将它们整合到UITabBarController中。
@interface __2AppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
UINavigationController *navController1;
UINavigationController *navController2;
UINavigationController *navController3;
UINavigationController *navController4;
UINavigationController *navController5;
UISegmentedControl *segmentedController;
UITabBarController *tabBarController;
}
 
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic,retain) IBOutlet UINavigationController *navController1;
@property (nonatomic,retain) IBOutlet UINavigationController *navController2;
@property (nonatomic,retain) IBOutlet UINavigationController *navController3;
@property (nonatomic,retain) IBOutlet UINavigationController *navController4;
@property (nonatomic,retain) IBOutlet UINavigationController *navController5;
@property (nonatomic,retain) IBOutlet UISegmentedControl *segmentedController;
@property (nonatomic,retain) IBOutlet UITabBarController *tabBarController;

 
@end


@synthesize window;
@synthesize navController1;
@synthesize navController2;
@synthesize navController3;
@synthesize navController4;
@synthesize navController5;
@synthesize segmentedController;
@synthesize tabBarController;


#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
    // Override point for customization after application launch.
    tabBarController = [[UITabBarController alloc] init];
 
 
homeViewController *homeController = [[homeViewController alloc] init];
homeController.title = @"蓝天l风烨堞";
navController1 = [[UINavigationController alloc] initWithRootViewController:homeController];
[homeController release];
 
 
messageViewController *messageController = [[messageViewController alloc] init];
messageController.title = @"信息";
UITabBarItem *item1 = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemHistory tag:0];
messageController.tabBarItem = item1;
[item1 release];
navController2 = [[UINavigationController alloc] initWithRootViewController:messageController];
[messageController release];
 
 
mineViewController *mineController = [[mineViewController alloc] init];
mineController.title = @"我的资料";
UITabBarItem *item2 = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemContacts tag:0];
mineController.tabBarItem = item2;
[item2 release];
navController3 = [[UINavigationController alloc] initWithRootViewController:mineController];
[mineController release];
 
 
searchViewController *searchController = [[searchViewController alloc] init];
searchController.title = @"搜索";
UITabBarItem *item3 = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemSearch tag:0];
searchController.tabBarItem = item3;
[item3 release];
navController4 = [[UINavigationController alloc] initWithRootViewController:searchController];
[searchController release];
 
 
moreViewController *moreController = [[moreViewController alloc] init];
moreController.title = @"更多";
UITabBarItem *item4 = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemMore tag:0];
moreController.tabBarItem = item4;
[item4 release];
navController5 = [[UINavigationController alloc] initWithRootViewController:moreController];
[moreController release];
 
 
NSArray *controllers = [NSArray arrayWithObjects:navController1,navController2,navController3,navController4,navController5,nil];
 
 
tabBarController.viewControllers = controllers;
 
 
[self.window addSubview:tabBarController.view];
    [self.window makeKeyAndVisible];
    
    return YES;
}

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值