zoukankan      html  css  js  c++  java
  • 源码03-02-07-LoadView

    //
    //  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

    本人无商业用途,仅仅是学习做个笔记,特别鸣谢小马哥,学习了IOS,另日语学习内容有需要文本和音频请关注公众号:riyuxuexishuji
  • 相关阅读:
    [navicat premium] [IM002] [Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序
    阿里云推荐码优惠享9折
    [eclipse]maven 编译时报错:编码 UTF-8 的不可映射字符
    Aqua Data Studio【下载】ads-windows-x64-16.0.5
    PL/SQL Develper配置Oracle client
    SecureCRT 访问本地Linux虚拟机NAT网络(VMware workstation 9+secureCRT+Ubuntu12.04)
    Spring官方下载地址
    dom4j创建XML文件
    azure devops
    html里如何获取每次点击select里的option值
  • 原文地址:https://www.cnblogs.com/laugh/p/6549794.html
Copyright © 2011-2022 走看看