Detailed IOS 7.1 Program startup principle

Source: Internet
Author: User

Programs are all imported from the Main method IOS is no exception

int main (int argc,char * argv[])

{

@autoreleasepool {

Return Uiapplicationmain (argc, argv, Nil, Nsstringfromclass ([Appdelegate class]));

}

}

In iOS, there's a uiapplicationmain inside the main method with 4 parameters.

Param 1:ARGC: Number of parameters corresponding to argv

param 2:argv: Parameter variable list (load-info.plist file information for application)

Param 3: Specifies the name of the UIApplication class or subclass. If nil is the default is UIApplication

PARAM 4: Sets the proxy object for the application. If nil, the proxy object is loaded from the application's main nib file.

Return value: This method generally does not return, even if the user clicked on the iOS home button, the program will move it into the background.

The Uiapplicationmain function returns when the program exits normally

When the program starts, it will come to Appdelegate, which inherits Uiresponder and follows the Uiapplicationdelegate

Uiresponder: Defines the interface for responding to and handling events, which is the parent class of UIApplication, UIWindow, UIView to receive user motion events and touch events

Program Start complete

(BOOL) Application: (UIApplication *) Applicationdidfinishlaunchingwithoptions: (Nsdictionary *) launchOptions

Program loses intersection

(void) Applicationwillresignactive: (uiapplication *) application

program into the background

(void) Applicationdidenterbackground: (uiapplication *) application
Procedures to enter the foreground

(void) Applicationwillenterforeground: (uiapplication *) application

Program Get focus

(void) Applicationdidbecomeactive: (uiapplication *) application

The program is about to close

(void) Applicationwillterminate: (uiapplication *) application

If the program does not set the primary startup storyboard file, and there is no

(BOOL) Application: (UIApplication *) Applicationdidfinishlaunchingwithoptions: (Nsdictionary *) launchOptions

method to set the Window object is not normal activity

Typically set in this method

(BOOL) Application: (UIApplication *) Applicationdidfinishlaunchingwithoptions: (Nsdictionary *) launchOptions

{

Self.window = [[Uiwindowalloc]initwithframe:[[uiscreenmainscreen]bounds]];

Self.window.backgroundColor = [Uicolorwhitecolor];

Self.viewcontroller =[[viewcontroller alloc] initwithnibname:@ "Viewcontroller" bundle:nil];

Setting the root View Controller

Self.window.rootViewController =self.viewcontroller;

Set the main view and the visible window has only one main view

[Self.windowmakekeyandvisible];

}

Now that you have the Window object, you can add a variety of view to customize the interface.

Otherwise, no window object can see any UI interface

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.