main.m → MainWindow.xib → XXXXXXDelegate.m → XXXXXXViewController.m → XXXXXXViewController.xib |
1.首先需要运行 main函数下的
UIApplicationMain(argc, argv,nil,NSStringFromClass([BIDAppDelegateclass]));
2.然后运行 applicationMain下的 mainWindow.xib 文件. 然后想 xib中的 file's owner 发送指定的delegate 消息.然后调用
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 这个方法.
3.如果
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions中添加了 子视图,那么就显示子视图.
4.如果子视图中加载完之后就将调用
self.switcherViewController = [[BIDSwitcherViewControlleralloc]initWithNibName:@"SwitchView"bundle:nil] 这样的方法.
5.接着就调用 XXXviewController.h方法,再调用XXXViewController.m方法,最终显示 依赖 .m中得 viewdidLoad 加载 view视图
下面是测试代码:
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"ViewController 中的 viewDidLoad 的调用");
UIButton *button = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 20, 20)];
[self.view addSubview:button];
NSLog(@"对Button的处理和调用.");
// Do any additional setup after loading the view, typically from a nib.
}
2013-12-02 13:11:16.032 helloworld[1880:c07] mian函数的接口
2013-12-02 13:11:23.229 helloworld[1880:c07] Appdelegate中的 didfinishLaunchingWith...的调用
2013-12-02 13:17:24.038 helloworld[1965:c07] 对Button的处理和调用.
2013-12-02 13:11:23.661 helloworld[1880:c07] Appdelegate中的 applicationDidBecomeActive...的调用
2013-12-02 13:12:47.399 helloworld[1880:c07] Appdelegate中的 applicationWillResignActive...的调用
点击了Home按钮
2013-12-02 13:12:47.401 helloworld[1880:c07] Appdelegate中的 applicationDidEnterBackground...的调用
2013-12-02 13:12:55.826 helloworld[1880:c07] Appdelegate中的 applicationWillEnterForeground...的调用
//点击了 app
2013-12-02 13:12:55.828 helloworld[1880:c07] Appdelegate中的 applicationDidBecomeActive...的调用