iPhone开发 使用tabbarcontroller
不可开启arc,否则报错- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
-
- {
-
- self.window = [[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]];
-
- // Override point for customization after application launch.
-
- self.window.backgroundColor = [UIColorwhiteColor];
-
-
-
- //生成各个视图控制器
-
- a* aa = [[a alloc]init];
-
- b* bb = [[b alloc]init];
-
- c* cc = [[c alloc]init];
-
- d* dd = [[d alloc]init];
-
- e* ee = [[e alloc]init];
-
- //加入一个数组
-
- NSArray* controllerArray = [[NSArray alloc]initWithObjects:aa,bb,cc,dd,ee ,nil];
-
- //创建UITabBarController控制器
-
- UITabBarController* tabBarController = [[UITabBarControlleralloc]init];
-
- // 设置委托
-
- tabBarController.delegate = self;
-
- //设置UITabBarController控制器的viewControllers属性为我们之前生成的数组controllerArray
-
- tabBarController.viewControllers = controllerArray;
-
- //默认选择第1个视图选项卡(索引从0开始的)
-
- tabBarController.selectedIndex = 0;
-
- //读取
-
- UIViewController* activeController = tabBarController.selectedViewController;
-
- if(activeController == aa){
-
- //
-
- }
-
- // 把tabBarController的view作为子视图添加到window
-
- [self.window addSubview:tabBarController.view];
-
-
-
- //定制按钮
-
- /*NSMutableArray* customzableViewControllers = [[NSMutableArray alloc]init];
-
- [customzableViewControllers addObject:musicList];
-
- [customzableViewControllers addObject:currentPlay];
-
- [customzableViewControllers addObject:favourite];
-
- tabBarController.customizableViewControllers = customzableViewControllers;
-
-
-
- tabBarController.customizableViewControllers = nil;
-
- */
-
- //
-
- // [musicList release];
-
- // [currentPlay release];
-
- // [favourite release];
-
- // [singerList release];
-
- // [settings release];
-
-
-
- [self.windowmakeKeyAndVisible];
-
- returnYES;
-
- }
复制代码 |