Chinaunix首页 | 论坛 | 博客
  • 博客访问: 307010
  • 博文数量: 53
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 325
  • 用 户 组: 普通用户
  • 注册时间: 2013-10-14 22:50
文章分类

全部博文(53)

文章存档

2014年(15)

2013年(38)

我的朋友

分类: iOS平台

2013-11-28 10:29:11

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
   
    //生成各个视图控制器
    MedicalData* aa = [[MedicalData alloc]init];
    HealthRecord* bb = [[HealthRecord alloc]init];
    KonwledgeBase* cc = [[KonwledgeBase alloc]init];
    CarePrescription* dd = [[CarePrescription alloc]init];
    //加入一个数组   
    NSArray* controllerArray = [[NSArray alloc]initWithObjects:aa,bb,cc,dd ,nil];
    //创建UITabBarController控制器  (定义在.h中,否在开启arc会自动释放掉,内存访问出错)
    tabBarController = [[UITabBarController alloc]init];
    //设置委托
    tabBarController.delegate = self;
    //设置UITabBarController控制器的viewControllers属性为我们之前生成的数组controllerArray
    tabBarController.viewControllers = controllerArray;
    //默认选择第1个视图选项卡(索引从0开始的)
    tabBarController.selectedIndex = 0;
    //设置TabBarItem的标题与图片
    [(UITabBarItem *)[tabBarController.tabBar.items objectAtIndex:0] setTitle:@"aa"]; 
    [(UITabBarItem *)[tabBarController.tabBar.items objectAtIndex:0] setImage:[UIImage imageNamed:@"1517.png"]];  //30 * 30
    [(UITabBarItem *)[tabBarController.tabBar.items objectAtIndex:1] setTitle:@"bb"];
    [(UITabBarItem *)[tabBarController.tabBar.items objectAtIndex:1] setImage:[UIImage imageNamed:@"light.png"]];
    [(UITabBarItem *)[tabBarController.tabBar.items objectAtIndex:2] setTitle:@"cc"];
    [(UITabBarItem *)[tabBarController.tabBar.items objectAtIndex:2] setImage:[UIImage imageNamed:@"podcaste.png"]];
    [(UITabBarItem *)[tabBarController.tabBar.items objectAtIndex:3] setTitle:@"dd"];
    [(UITabBarItem *)[tabBarController.tabBar.items objectAtIndex:3] setImage:[UIImage imageNamed:@"setting.png"]];
    [(UITabBarItem *)[tabBarController.tabBar.items objectAtIndex:4] setTitle:@"ee"];
    [(UITabBarItem *)[tabBarController.tabBar.items objectAtIndex:4] setImage:[UIImage imageNamed:@"unlock.png"]];
    //读取
    UIViewController* activeController = tabBarController.selectedViewController;
    if(activeController == aa){
        //
    }
    //把tabBarController的view作为子视图添加到window
    [self.window addSubview:tabBarController.view];
    [self.window makeKeyAndVisible];
    return YES;

}

阅读(648) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~