免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1783 | 回复: 1
打印 上一主题 下一主题

iPhone开发 使用tabbarcontroller [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2012-03-05 15:55 |只看该作者 |倒序浏览
iPhone开发 使用tabbarcontroller





不可开启arc,否则报错
  1. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

  2. {

  3.     self.window = [[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]];

  4.     // Override point for customization after application launch.

  5.     self.window.backgroundColor = [UIColorwhiteColor];

  6.    

  7.     //生成各个视图控制器

  8.     a* aa = [[a alloc]init];

  9.     b* bb = [[b alloc]init];

  10.     c* cc = [[c alloc]init];

  11.     d* dd = [[d alloc]init];

  12.     e* ee = [[e alloc]init];

  13.     //加入一个数组   

  14.     NSArray* controllerArray = [[NSArray alloc]initWithObjects:aa,bb,cc,dd,ee ,nil];

  15.     //创建UITabBarController控制器  

  16.     UITabBarController* tabBarController = [[UITabBarControlleralloc]init];

  17.     //    设置委托

  18.     tabBarController.delegate = self;

  19.     //设置UITabBarController控制器的viewControllers属性为我们之前生成的数组controllerArray

  20.     tabBarController.viewControllers = controllerArray;

  21.     //默认选择第1个视图选项卡(索引从0开始的)

  22.     tabBarController.selectedIndex = 0;

  23.     //读取

  24.     UIViewController* activeController = tabBarController.selectedViewController;

  25.     if(activeController == aa){

  26.         //

  27.     }

  28.     //    把tabBarController的view作为子视图添加到window

  29.     [self.window addSubview:tabBarController.view];

  30.    

  31.     //定制按钮

  32.     /*NSMutableArray* customzableViewControllers = [[NSMutableArray alloc]init];

  33.      [customzableViewControllers addObject:musicList];

  34.      [customzableViewControllers addObject:currentPlay];

  35.      [customzableViewControllers addObject:favourite];

  36.      tabBarController.customizableViewControllers = customzableViewControllers;

  37.      

  38.      tabBarController.customizableViewControllers = nil;

  39.      */

  40.     //

  41. //    [musicList release];

  42. //    [currentPlay release];

  43. //    [favourite release];

  44. //    [singerList release];

  45. //    [settings release];

  46.    

  47.     [self.windowmakeKeyAndVisible];

  48.     returnYES;

  49. }
复制代码

论坛徽章:
0
2 [报告]
发表于 2012-03-05 15:56 |只看该作者
谢谢分享
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP