iOS tabbar 控制器基本使用

时间:2014-05-16 07:02:10   收藏:0   阅读:396
bubuko.com,布布扣
 RootViewController *rootVC=[[RootViewController alloc] init]
    
    SignInViewController *signVC = [[SignInViewController alloc]init];
    //如果在这里指定tabitem标题,则在FirstViewController中指定self.tabBarItem.title则不生效
    signVC.title = @"打卡";
    UITabBarItem *signItem = [[UITabBarItem alloc]initWithTitle:@"打卡" image:nil tag:1];
    [signItem setFinishedSelectedImage:[UIImage imageNamed:@"p1"] withFinishedUnselectedImage:[UIImage imageNamed:@"p1_f"]];
    signVC.tabBarItem = signItem;
    
    TextViewController *textVC = [[TextViewController alloc]init];
    signVC.title = @"备注";
    UITabBarItem *textItem = [[UITabBarItem alloc]initWithTitle:@"备注" image:nil tag:2];
    [textItem setFinishedSelectedImage:[UIImage imageNamed:@"p1"] withFinishedUnselectedImage:[UIImage imageNamed:@"p1_f"]];
    textVC.tabBarItem = textItem;
    
    VisitViewController *visitVC = [[VisitViewController alloc]init];
    visitVC.title = @"拜访";
    UITabBarItem *visitItem = [[UITabBarItem alloc]initWithTitle:@"拜访" image:nil tag:3];
    [visitItem setFinishedSelectedImage:[UIImage imageNamed:@"p1"] withFinishedUnselectedImage:[UIImage imageNamed:@"p1_f"]];
    visitVC.tabBarItem = visitItem;
    //构建UITabBarController并指定代理为本身
    self.tabBarController = [[UITabBarController alloc]init];
    self.tabBarController.delegate = self;
    
    //为UITabBarController添加TabBarItem
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:textVC,signVC,visitVC, nil];
    //设置选中哪个tab
    [self.tabBarController setSelectedIndex:1];
    self.window.backgroundColor = [UIColor whiteColor];
    //指定根视图
    self.window.rootViewController  = self.tabBarController;
bubuko.com,布布扣

 

iOS tabbar 控制器基本使用,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!