IPHONE应用开发 - xib关联到appdelegate

来源:互联网 发布:c语言中文网官网 编辑:程序博客网 时间:2024/05/16 06:03

1.创建Empty application,此时项目中只有一个AppDelegate的类

Start with Empty Application template

2.新建文件,选择User Interface下的Empty 命名为MainWindow

Add Empty Interface Builder document

3.打开新建的MainWindow.xib文件

The empty design surface of MainWindow.xib

 

 

 

4.将File's Owner的类名修改为UIApplication

Change class of File's Owner to UIApplication

5. 在Library中拖放一个Object到图下的位置

Add Object to the document

6.将该object的类名修改为文件中AppDelegate的类名(同时还可以给object命名下Label)

Change class of the object to xAppDelegate

7.拖放一个Window到左边

Add a window to the document

8. 在xAppDelegate的h文件中,给window的属性加上IBOutlet

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

 

 

9.将File's Owner 和 拖放的Object按照以下方式连接

Link the application delegate

 

Link the window outlet of the app delegate

 

 

10.在项目属性中,把Main Interface修改成你的xib文件名MainWindow

Set the Main Interface to MainWindow

11. 在xAppDelegate.m文件中,将

- (BOOL) application:didFinishLaunchingWithOptions:
0 0