zoukankan      html  css  js  c++  java
  • 在XCode4.2中添加MainWindow.xib文件

    xcode4.2推荐使用storyboard,但网上资料太少,书上讲的也都是基于xib的

    花了2天时间,终于把xib的helloWorld写出来了。

    注意,类名一定要大写,为了这个东西,我搞了2天,在配viewContorller时一直抛错。

    新建 Empty Application



     添加一个object,添加一个View Controller,添加一个window,

    把File's Owner的 custom  class 改成 UIApplication


    把Object的custom class 改成 自己的 delegate,我的是HelloAppDelegate

    然后新建 Cocoa Touch 下的UIViewControllersubclass



     拖一个label进去,写上hello world

    然后,回到MainWindow中,把ViewController的custom class 改成HelloViewController

    然后拖线:

    File's Owner拖到  delegate,从delegate拖到viewcontroller和window

    然后修改代理类里的

    C代码 复制代码 收藏代码
    1. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions   
    2. {   
    3.     //self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];   
    4.     // Override point for customization after application launch.   
    5.     //self.window.backgroundColor = [UIColor whiteColor];   
    6.     [self.window addSubview: self.viewController.view];   
    7.     [self.window makeKeyAndVisible];   
    8.     return YES;   
    9. }  
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        //self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
        // Override point for customization after application launch.
        //self.window.backgroundColor = [UIColor whiteColor];
        [self.window addSubview: self.viewController.view];
        [self.window makeKeyAndVisible];
        return YES;
    }

    运行即可~

  • 相关阅读:
    IIS浏览显示目录
    图解NuGet的安装和使用
    未能找到类型或命名空间名称“DbContext”
    IIS报错:未将对象引用设置到对象的实例
    最新11位手机号正则表达式
    Sql Server连表查询字段为null
    sql server 表连接
    2019用卡提额攻略
    win10,7 80端口被占用的检测和解决方法
    SAP之RFC_READ_TABLE
  • 原文地址:https://www.cnblogs.com/zhwl/p/2848887.html
Copyright © 2011-2022 走看看