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 中编写视图了。

  • 相关阅读:
    VIE模式和IP
    背景色改为豆绿色
    Semantic Logging
    mysql 安装配置相关
    高德API相关
    vmware workstation 虚拟机安装vwmare tools
    sql server2012光盘中有management studio,安装时选择客户端。
    zz微软企业库
    zz flag attribute for enum
    zz 还要用存储过程吗
  • 原文地址:https://www.cnblogs.com/llguanli/p/8404037.html
Copyright © 2011-2022 走看看