ios成长之每日一遍(day 1)
Hello world开始。
这里不讨论如何创建项目导入项目。由于趁上班时间打酱油所以也不谈细节, 只谈具体项目的实现与关键流程的解析, 只供本人实际程况使用。不喜请移驾。
首先来谈谈 AppDelegate.h与AppDelegate.m 文件
AppDelegate.h:
#import <UIKit/UIKit.h> @class BIDViewController; // 声明引用的文件 @interface BIDAppDelegate : UIResponder <UIApplicationDelegate> // 实现UIApplicationDelegate协议中的方法,用于处理UIApplication接收的事件 @property (strong, nonatomic) UIWindow *window; // UIView的子类, 是所有UIView的根,管理和协调的应用程序的显示 @property (strong, nonatomic) BIDViewController *viewController; @end
AppDelegate.m:
#import "BIDAppDelegate.h" #import "BIDViewController.h" @implementation BIDAppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // 初始化UIWindow // Override point for customization after application launch. self.viewController = [[BIDViewController alloc] initWithNibName:@"BIDViewController" bundle:nil]; // 初始化BIDViewController并且指定controller的xib文件, xib文件就是布局文件 self.window.rootViewController = self.viewController; // 指定window的根视图控制器 [self.window makeKeyAndVisible]; // 让window显示在屏幕上 return YES; } - (void)applicationWillResignActive:(UIApplication *)application { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - (void)applicationDidEnterBackground:(UIApplication *)application { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - (void)applicationWillEnterForeground:(UIApplication *)application { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } - (void)applicationDidBecomeActive:(UIApplication *)application { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - (void)applicationWillTerminate:(UIApplication *)application { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } @end
由于是hello world, BIDViewController也没有什么东西, 只是一个简单的文本, 因此就不挪来说了, 至此第一篇ios的开端已经结束。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。