Appdelegate Life Cycle Detailed

Source: Internet
Author: User

#pragma mark calls after the application has finished loading

-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions

{

NSLog (@ "didfinishlaunchingwithoptions-loading complete");

Initialize a window

Self.window = [[[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]] autorelease];

Incoming xib file name to initialize a controller

Self.viewcontroller = [[[Mjviewcontroller alloc] initwithnibname:@ "Mjviewcontroller" Bundle:nil] autorelease];

Setting the root controller of a window

Self.window.rootViewController = Self.viewcontroller;

The following code is executed inside the code above:

[Self.window AddSubview:self.viewController.view];

The window does not appear by default and requires a method to be called to display

Keywindow is the main window, only the main window can interact with the user normally

[Self.window makekeyandvisible];

Self.window.hidden = NO;

return YES;

}

Called when the mark program loses focus #pragma (cannot interact with the user)

-(void) Applicationwillresignactive: (uiapplication *) application

{

NSLog (@ "applicationwillresignactive-loses focus");

}

#pragma mark is called when the application enters the background (click the Home button)

-(void) Applicationdidenterbackground: (uiapplication *) application

{

NSLog (@ "applicationdidenterbackground-into the background");

}

#pragma mark calls when the application enters the foreground

-(void) Applicationwillenterforeground: (uiapplication *) application

{

NSLog (@ "applicationwillenterforeground-Enter the front desk");

}

#pragma mark calls when the application gets focus

Get focus before you can interact with the user

-(void) Applicationdidbecomeactive: (uiapplication *) application

{

NSLog (@ "applicationdidbecomeactive-get Focus");

}

This method is called when the #pragma mark program is terminated in some cases

-(void) Applicationwillterminate: (uiapplication *) application

{

NSLog (@ "applicationwillterminate-is closed");

}

After the project starts:

first one IOS program [517:c07] didfinishlaunchingwithoptions- Load Complete

first one IOS program [517:c07] applicationdidbecomeactive- Get Focus

Press the home button:   first one IOS program [517:c07] applicationwillresignactive- Lose Focus

first one IOS program [517:c07] applicationdidenterbackground- Go Backstage

Then press the program:

first one IOS program [517:c07] applicationwillenterforeground- Access to reception

first one IOS program [517:c07] applicationdidbecomeactive- Get Focus

Appdelegate Life Cycle Detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.