首页 > 其他分享 >xcode4.2中使用xib来运行hello world (MainWindow.xib)

xcode4.2中使用xib来运行hello world (MainWindow.xib)

时间:2023-04-03 16:32:06浏览次数:53  
标签:KB xib self custom window delegate MainWindow xcode4.2


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

 

然后修改代理类里的


- (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;
}


 

运行即可~

 

 

 


  • xcode4.2中使用xib来运行hello world (MainWindow.xib)_代理类

  • 大小: 44.4 KB
  • xcode4.2中使用xib来运行hello world (MainWindow.xib)_bc_02

  • 大小: 23 KB
  • xcode4.2中使用xib来运行hello world (MainWindow.xib)_bc_03

  • 大小: 26.1 KB
  • 查看图片附件


标签:KB,xib,self,custom,window,delegate,MainWindow,xcode4.2
From: https://blog.51cto.com/u_21817/6166749

相关文章

  • 关于lib-flexible插件中的单位转换
    lib-flexible是淘宝项目组开发出来的一个小插件,属于开源项目。一般而言,lib-flexible并不独立出现,而是搭配px2rem-loader一起做适配方案,目的是自动将css中的px转换成rem。lib-flexible:根元素html的font-size为此时屏幕宽度/10,也就有1rem=html的font-size大小。1.但是当分辨率(屏......
  • QMainWindow知识点记录
    1.新建action toolbaropenFileAction = new QAction(QIcon(":/pic/open"), QString::fromLocal8Bit("打开"), this); openFileAction->setShortcut(tr("Ctrl+O")); openFileAction->setStatusTip(tr("打开一个文件"));-------......
  • Codeforces Round #848 (Div. 2)D. Flexible String Revisit-dp、初等数学
    题目:https://codeforces.com/problemset/problem/1778/D场内打的,首先很容易想到答案来自于a、b不同的位置有几个,设\(f_k\)表示当前有k个不同的位置要复原到完全一样需要多......
  • QMainWindow简介
        QMainWindow是带有菜单栏、工具栏、状态栏的主窗口类,它有自己单独的布局。布局有一个中心区域,通常是标准的Qt部件,也可以是定制部件,且必须有一个中心小部件。set......
  • Flexible String
    题目链接题目描述:Youhaveastring\(a\)andastring\(b\).Bothofthestringshavelength\(n\).Thereareatmost10differentcharactersinthestringa.......
  • xib起冲突 StartTag: invalid element name
    <欢迎大家加入iOS开发学习交流群:QQ529560119>首先要表明下心态,代码已经推到到了项目分支,跑步起来xib点不开,双击就报错line:XX StartTag:invalidelementname,感觉真的挂了......
  • Azure ARM (27) 自定义Role,只能创建MySQL Flexible Server资源
    《WindowsAzurePlatform系列文章目录》 用户这里有个新的需求,自定义Role,只能创建MySQLFlexibleServer资源和PrivateDNSZone,不能创建资源资源。可以......
  • 3.PyQt5【窗口组件】主窗口-QMainWindow
    一、前言QMainWindow类提供一个有菜单条、锚接窗口(例如工具条)和一个状态条的主应用程序窗口。主窗口通常用在提供一个大的中央窗口部件(例如文本编辑或者绘制画布)以及周围......
  • QT学习之QMainWindow详解
    文章目录​​1、菜单栏​​​​2、工具栏​​​​3、状态栏​​​​4、铆接部件​​​​5、核心部件(中心部件)​​​​6、资源文件​​有关QT的学习我们会采取连载更新,传送门......
  • Terraform to create an Azure Database for MySQL - Flexible Server
    TerraformtocreateanAzureDatabaseforMySQL-FlexibleServerhttps://learn.microsoft.com/en-us/azure/mysql/flexible-server/quickstart-create-terraform?tab......