xcode4.2手动添加MainWindow.xib

本文详细介绍了如何通过创建一个简单的iOS应用程序来理解iOS应用的启动过程。从建立空项目开始,逐步介绍了添加xib文件、配置UIApplication、设置窗口及代理等步骤。

参考来自:http://blog.youkuaiyun.com/muyu114/article/details/6896498

1、新建一个空的应用程序

Start with Empty Application template

2、添加一个空的xib文件

 Add Empty Interface Builder document

到这里工程的应该是下面这个样子的:

The empty design surface of MainWindow.xib

3、改变File’s Owner的class为UIApplication

Change class of File's Owner to UIApplication

4、从Library中添加一个Object,并设置其class为你对应的应用程序的类(这里是DemoAppDelegate)

Add Object to the document

Change class of the object to xAppDelegate

5、添加windows,并在程序中设置windows为IBOutlet

Add a window to the document

The xAppDelegate.h should read something like this:

@interface DemoAppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) IBOutlet UIWindow *window; @end
 
 

6、将windows与xib中的文件连接起来,并设置相应的代理

Link the application delegate

  • Control-Drag from the window outlet of the xAppDelegate to the Window.

Link the window outlet of the app delegate

  • Just for this demo, I’m adding a label to the window.

Add a label for testing

7、设置应用程序的主界面

  • Navigate to the project, and in the Summary tab, select MainWindow as the Main Interface.

Set the Main Interface to MainWindow

You can now run the project in the Simulator, and the window should show up. However there’s one last thing you might want to clean up. In xAppDelegate.m, there was actually code that creates a window as well. Just put the method

- (BOOL) application:didFinishLaunchingWithOptions:

in comment.

we're done

 

 

I hope this helps to understand exactly how an iOS app starts. The next thing you should do is add a ViewController, and push it onto the MainWindow. I’m not going to cover that here. Please leave your feedback in the comments.

转载于:https://www.cnblogs.com/foxmin/archive/2012/04/06/2434437.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值