zoukankan      html  css  js  c++  java
  • UI_搭建MVC

    新建RootViewController 继承于 UIViewController
    新建RootView 继承于 UIView
    AppDelegate.m 中引入 #import "RootViewController.h"

    #pragma mark - 重写
    #pragma mark dealloc
    - (void)dealloc
    {
        [_window release];
        [super dealloc];
    }
    
        //设置window
        self.window = [[[UIWindow alloc] init] autorelease];
        self.window.frame = [UIScreen mainScreen].bounds;
        self.window.backgroundColor = [UIColor whiteColor];
        [self.window makeKeyAndVisible];
    
        // 设置根视图控制器
        RootViewController *rootVC = [[RootViewController alloc] init];
        self.window.rootViewController = rootVC;
        [rootVC release];

    RootViewController.m 中引入 #import "RootView.h"

    @interface RootViewController ()
    
    @property (nonatomic, retain) RootView *rootView;
    
    @end
    #pragma mark - 重写
    #pragma mark dealloc
    - (void)dealloc
    {
        [_rootView release];
        [super dealloc];
    }

    编写 loadView 函数,函数中永远仅仅写三句话

    - (void)loadView
    {
        // 设置当前视图为根视图
        self.rootView = [[RootView alloc] initWithFrame:[UIScreen mainScreen].bounds];
        self.view = self.rootView;
        [_rootView release];
    
    }

    能够在 RootView.m 中编写视图了。

  • 相关阅读:
    LightOJ--1094-- Farthest Nodes in a Tree(树的直径裸题)
    poj--1383--Labyrinth(树的直径)
    C字符数组和C++字符串
    Miracl库学习
    GBDT学习
    Java编程规范
    关于JS中的数组[]的方法
    焦点离开事件
    Firebug 安装方法
    JAVASE 中的String的字符串
  • 原文地址:https://www.cnblogs.com/llguanli/p/8404037.html
Copyright © 2011-2022 走看看