源码03-02-07-LoadView
2017-03-14 17:51
169 查看
// // AppDelegate.m // 07-控制器View的创建 #import "AppDelegate.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; // 加载箭头指向的控制器 UIViewController *vc = [storyboard instantiateInitialViewController]; self.window.rootViewController = vc; [self.window makeKeyAndVisible]; return YES; } @end
// // ViewController.m // 07-控制器View的创建 #import "ViewController.h" @interface ViewController () @end @implementation ViewController // loadView作用:自定义控制器的view // loadView什么时候调用:第一次使用控制器的view的时候调用 // 注意:在这个方法中如果没有自定义view,就不能获取控制器的view // 一旦重写了这个方法,就不要调用[super loadView] // 如果重写了这个方法,就不会去加载storyboard描述的控制器的View - (void)loadView { // self.view.backgroundColor = [UIColor redColor]; // // 创建控制器view self.view = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds]; // self.view.backgroundColor = [UIColor purpleColor]; } //- (UIView *)view //{ // if (_view == nil) { // [self loadView]; // // [self viewDidLoad]; // } // return _view; //} #pragma mark - 直接不实现就是系统默认的做法 //- (void)loadView //{ // // super -> UIViewController // // 系统默认的做法,一定不要这样写 // [super loadView]; // //} - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end
相关文章推荐
- 源码推荐(03.02B):卡片式切换仿支付宝五福效果,横向滑动
- 源码03-02-09-控制器View懒加载
- 源码03-02-10-导航控制器简单使用
- STL源码解析-02配置器-03自定义配置器
- 源码03-02-03-04-UIWindow
- 源码03-02-05-控制器的创建(storyboard)
- 3 视频里weekend05、06、07的可靠性 + HA原理、分析、机制 + weekend01、02、03、04、05、06、07的分布式集群搭建
- 03网络请求_02_Volley_4_带你从源码的角度理解Volley
- 源码-0205-02--表格数据的批量操作03
- 给定一个字符串,里面用空格分开为多个(>=6)部分组合,如:01 02 03 04 05 06 07 …… 写一个函数返回任意6个组合的字符串: 输出格式实例: 01 02 03 04 05 06 0
- 03-redhat-6.5升级python2.6到python2.7&安装psycopg2&连接postgresql-9.6.1(201-02-07)
- 源码03-02-08-控制器View的创建(XIB)
- android Launcher源码解析07:Workspace 02——设置壁纸
- (原创)c#学习笔记02--编写c#程序03--Windows Forms应用程序
- 【转】Java 集合系列03之 ArrayList详细介绍(源码解析)和使用示例
- java实现在线预览----poi操作word转html及03、07版本兼容问题
- Java【集合系列】-03-ArrayList详细介绍(源码解析)和使用示例
- 20161224C++阶段班02_C to C++_03引用/指针/引用传参和返回值
- 本周ASP.NET英文技术文章推荐[02/24 - 03/01]:Silverlight、AJAX、Web Client Software Factory、LINQ、上传文件、GDI+
- [导入]【03-27】【美国】【07最新恐怖大片】《夺命停车场》【DVD中英双字幕】【22:45发布】