码迷,mamicode.com
首页 > 移动开发 > 详细

iOS tabbar 控制器基本使用

时间:2014-05-16 07:02:10      阅读:396      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   c   java   

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

iOS tabbar 控制器基本使用

标签:style   blog   class   code   c   java   

原文地址:http://www.cnblogs.com/someonelikeyou/p/3726196.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!