参考来自:http://blog.csdn.net/muyu114/article/details/6896498
1、新建一个空的应用程序
2、添加一个空的xib文件
到这里工程的应该是下面这个样子的:
3、改变File’s Owner的class为UIApplication
4、从Library中添加一个Object,并设置其class为你对应的应用程序的类(这里是DemoAppDelegate)
5、添加windows,并在程序中设置windows为IBOutlet
The xAppDelegate.h should read something like this:
@interface DemoAppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) IBOutlet UIWindow *window; @end
6、将windows与xib中的文件连接起来,并设置相应的代理
- Control-Drag from the window outlet of the xAppDelegate to the Window.
- Just for this demo, I’m adding a label to the window.
7、设置应用程序的主界面
- Navigate to the project, and in the Summary tab, select MainWindow as the Main Interface.
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.
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.