1. Switch Home key: COMMAND + SHIFT + H;2. Info.plist application does not run in background YES ****************************main******************************
1<font size="3">#import<UIKit/UIKit.h>2 #import "AppDelegate.h"3 4 intMainintargcChar*argv[]) {5 @autoreleasepool {6 returnUiapplicationmain (argc, argv, Nil, nsstringfromclass ([appdelegateclass]));7 //parameter Three: uiapplication instance object (unique)8 //[uiapplication sharedapplication] can be used to get application-unique object notifications9 //parameter Four: Specifies the proxy class for the current application. Used to process life-cycle related methods. If the program starts a callback method, program memory is not sufficient callback method, the program exits the callback method. Ten One } A } -appdelegate.h************ - #import<Foundation/Foundation.h> the #import<UIKit/UIKit.h> - //proxy classes for Applications - @interfaceAppdelegate:uiresponder <UIApplicationDelegate> - +@property (Strong, nonatomic) UIWindow *window;//_window - + @end</font>
*************************appdelegate.h*************************
1 <font size= " 3 > #import <foundation/ Foundation.h>2 #import <uikit/ Uikit.h>3 // The application's proxy class 4 @interface Appdelegate:uiresponder <uiapplicationdelegate>5 6 @ Property (Strong, Nonatomic) UIWindow *window; // _window 7 @end </font>
*************************appdelegate.m*************************
1<font size="3">#import "AppDelegate.h"2 3 @interfaceappdelegate ()4 5 @end6 7 @implementationappdelegate8 9 //the callback method once the program starts. Ten-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions { One //To explain Auiviewcontroller* CTR =[[Uiviewcontroller alloc] init]; - [Self.window setrootviewcontroller:ctr]; - the //Gets the width and height of the current device's screen -CGRect rect = [[UIScreen mainscreen] bounds];//CGRect relative to himself - //the creation process of the main window -Self.window = [[UIWindow alloc] Initwithframe:cgrectmake (0,0, Rect.size.width, Rect.size.height)];//view: Relative to another view + -[Self.window makekeyandvisible];//make the main window visible + ASelf.window.backgroundColor = [Uicolor Greencolor];//set the main window background color at - returnYES; - } - //The program is about to cancel the active state callback method. -- (void) Applicationwillresignactive: (UIApplication *) Application {} - in //how the program actually goes back in the background -- (void) Applicationdidenterbackground: (UIApplication *) Application {} to + //the procedure is about to enter the foreground callback method -- (void) Applicationwillenterforeground: (UIApplication *) Application {} the * //method that will callback when the program is active $- (void) Applicationdidbecomeactive: (UIApplication *) Application {}Panax Notoginseng - //Once the device does not support background operation, clicking the Home button will call back this method. the- (void) Applicationwillterminate: (UIApplication *) Application {} + A @end</font>
Iphone first day note March 28, 2016 (Monday) a.m. iphone development Introduction