[iOS基础控件 - 6.12.1] QQ菜单管理 UITabBarController 控制器管理

- 初始化UITabBarController
- 设置UIWindow的rootViewController为UITabBarController
- 根据具体情况,通过addChildViewController方法添加对应个数的子控制器
- 添加单个子控制器
- 设置子控制器数组

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// 设置window
self.window = [[UIWindow alloc] init];
self.window.frame = [[UIScreen mainScreen] bounds];
self.window.backgroundColor = [UIColor grayColor];
[self.window makeKeyAndVisible];
// 设置一个UITabBarController
UITabBarController *tabBarController = [[UITabBarController alloc] init];
self.window.rootViewController = tabBarController;
// 添加子控制器
UIViewController *c1 = [[UIViewController alloc] init];
c1.view.backgroundColor = [UIColor redColor];
// [tabBarController addChildViewController:c1];
UIViewController *c2 = [[UIViewController alloc] init];
c2.view.backgroundColor = [UIColor blueColor];
// [tabBarController addChildViewController:c2];
UIViewController *c3 = [[UIViewController alloc] init];
c3.view.backgroundColor = [UIColor greenColor];
tabBarController.viewControllers = @[c1,c2,c3];
return YES;
}


标题文字
@property(nonatomic,copy) NSString *title;
图标
@property(nonatomic,retain) UIImage *image;
选中时的图标
@property(nonatomic,retain) UIImage *selectedImage;
提醒数字
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// 设置window
self.window = [[UIWindow alloc] init];
self.window.frame = [[UIScreen mainScreen] bounds];
self.window.backgroundColor = [UIColor grayColor];
[self.window makeKeyAndVisible];
// 设置一个UITabBarController
UITabBarController *tabBarController = [[UITabBarController alloc] init];
self.window.rootViewController = tabBarController;
// 添加子控制器
UIViewController *c1 = [[UIViewController alloc] init];
c1.view.backgroundColor = [UIColor redColor];
c1.tabBarItem.title = @"红色";
// [tabBarController addChildViewController:c1];
UIViewController *c2 = [[UIViewController alloc] init];
c2.view.backgroundColor = [UIColor blueColor];
c2.tabBarItem.title = @"蓝色";
// [tabBarController addChildViewController:c2];
UIViewController *c3 = [[UIViewController alloc] init];
c3.view.backgroundColor = [UIColor greenColor];
c3.tabBarItem.title = @"绿色";
tabBarController.viewControllers = @[c1,c2,c3];
return YES;
}






- (void)viewDidLoad {
[super viewDidLoad];
NSLog(@"%@ - viewDidLoad", self.class);
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSLog(@"%@ - viewWillAppear", self.class);
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSLog(@"%@ - viewDidAppear", self.class);
}
- (void) viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
NSLog(@"%@ - viewWillDisappear", self.class);
}
- (void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
NSLog(@"%@ - viewDidDisappear", self.class);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
NSLog(@"%@ - didReceiveMemoryWarning", self.class);
}
- (void)viewWillUnload {
[super viewWillUnload];
NSLog(@"%@ - viewWillUnload", self.class);
}
- (void)viewDidUnload {
[super viewDidUnload];
NSLog(@"%@ - viewDidUnload", self.class);
}
2014-12-27 21:11:44.340 UITabBarControllerByStoryboard[22567:590996] OneViewController - viewWillAppear
2014-12-27 21:12:10.042 UITabBarControllerByStoryboard[22567:590996] TwoViewController - viewWillAppear
2014-12-27 21:12:10.042 UITabBarControllerByStoryboard[22567:590996] OneViewController - viewWillDisappear
2014-12-27 21:12:10.054 UITabBarControllerByStoryboard[22567:590996] OneViewController - viewDidDisappear



[iOS基础控件 - 6.12.1] QQ菜单管理 UITabBarController 控制器管理的更多相关文章
- [iOS基础控件 - 6.9.3] QQ好友列表Demo TableView
A.需求 1.使用plist数据,展示类似QQ好友列表的分组.组内成员显示缩进功能 2.组名使用Header,展示箭头图标.组名.组内人数和上线人数 3.点击组名,伸展.缩回好友组 code so ...
- [iOS基础控件 - 6.12.3] @property属性 strong weak copy
A.概念 @property 的修饰词 strong: 强指针/强引用(iOS6及之前是retain) weak: 弱智真/弱引用(iOS6及之前是assign) 默认情况所有指针都是强指针 ...
- [iOS基础控件 - 6.12.2] Modal
A.概念 1.也可以用来切换控制器 2.如ActionSheet 除了push之外,还有另外一种控制器的切换方式,那就是Modal 任何控制器都能通过Modal的形式展示出来 Modal的默认效果 ...
- [iOS基础控件 - 6.12.4] NavigationController vs TabBarController
A.属性 1. Item NavigationController: navigationItem (不需要创建) title rightBarButtonItems/ rightBarButtonI ...
- [iOS基础控件 - 5.5] 代理设计模式 (基于”APP列表"练习)
A.概述 在"[iOS基础控件 - 4.4] APP列表 进一步封装,初见MVC模式”上进一步改进,给“下载”按钮加上效果.功能 1.按钮点击后,显示为“已下载”,并且不 ...
- [iOS基础控件 - 3.1] QQ登陆界面
A.storyboard 控件版 1.label 2.textfield a.Keyboard Type 账号:Number Pad 密码:Num ...
- iOS 基础控件(下)
上篇介绍了UIButton.UILabel.UIImageView和UITextField,这篇就简短一点介绍UIScrollView和UIAlertView. UIScrollView 顾名思义也知 ...
- [iOS基础控件 - 6.11.3] 私人通讯录Demo 控制器的数据传递、存储
A.需求 1.搭建一个"私人通讯录"Demo 2.模拟登陆界面 账号 密码 记住密码开关 自动登陆开关 登陆按钮 3.退出注销 4.增删改查 5.恢复数据(取消修改) 这个代码 ...
- [iOS基础控件 - 6.10.2] PickerView 自定义row内容 国家选择Demo
A.需求 1.自定义一个UIView和xib,包含国家名和国旗显示 2.学习row的重用 B.实现步骤 1.准备plist文件和国旗图片 2.创建模型 // // Flag.h // Co ...
随机推荐
- TeeChart显示三维的图形,使用Surface
绘制一个球 根据公式x^2+y^2+z^2=R^2; 令x=RsinAcosB y=RcosAcosB z=RsinB using System; using System.Collections. ...
- Android仿iPhone晃动撤销输入功能(微信摇一摇功能)
重力传感器微信摇一摇SensorMannager自定义alertdialogSensorEventListener 很多程序中我们可能会输入长文本内容,比如短信,写便笺等,如果想一次性撤销所有的键入内 ...
- MVC的项目使用html编辑器UEditorMINI
一个MVC的项目中有个发布新闻的页面需要用到一个html的编辑器,网上看到UEditor评价貌似还不错, 因为我用到的功能比较简单,就下载了MINI版本的, 使用的过程在这里总结一下. 关于UEdit ...
- Android Configuration change引发的问题及解决方法(转)
之前在学习Fragment和总结Android异步操作的时候会在很多blog中看到对Configuration Change的讨论,以前做的项目都是固定竖屏的,所以对横竖屏切换以及横竖屏切换对程序有什 ...
- mysql 索引与优化like查询
索引与优化like查询 1. like %keyword 索引失效,使用全表扫描.但可以通过翻转函数+like前模糊查询+建立翻转函数索引=走翻转函数索引,不走全表扫描. 2. like key ...
- ZOJ 1455 Schedule Problem(差分约束系统)
// 题目描述:一个项目被分成几个部分,每部分必须在连续的天数完成.也就是说,如果某部分需要3天才能完成,则必须花费连续的3天来完成它.对项目的这些部分工作中,有4种类型的约束:FAS, FAF, S ...
- MVC中前台所得
前台页面时间格式修改: @item.CreateTime.ToString("yyyy-MM-dd hh:mm:ss") 前台方法调用传参数: <a href="# ...
- andeoid学习笔记七
Android中Broadcast的Intent大全 Api Level 3:(SDK 1.5) android.bluetooth.a2dp.intent.action.SINK_STATE_CHA ...
- android学习笔记五
Android中的category大全 Api Level 3(SDK 1.5)和Api Level 4(SDK 1.6): android.intent.category.ALTERNATIVE a ...
- 【转】一致性hash算法(consistent hashing)
consistent hashing 算法早在 1997 年就在论文 Consistent hashing and random trees 中被提出,目前在 cache 系统中应用越来越广泛: 1 ...