首页 > 移动平台 > 详细

iOS tabbar 控制器基本使用

时间:2014-05-16 07:00:00      阅读:348      评论:0      收藏:0      [点我收藏+]
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 控制器基本使用

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!