[iOS base Control-6.10.6] Uiapplicationdelegate

Source: Internet
Author: User

A. Concept1. Mobile app is very susceptible to other system, software event interference, such as call, lock screen 2.app is disturbed, UIApplication will notify delegate, to Agent processing interference event 3.delegate can handle events (1) App Declaration cycle (start , close) (2) system events (incoming calls) (3) Emergency (Memory warning) B. UseConditions called delegate: compliance with the Uiapplicationdelegate Protocol project will be created automatically: Appdelegate 1.delegate method
1-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {2NSLog (@"called when the app is up and ready");3     returnYES;4 }5 6- (void) Applicationdidreceivememorywarning: (UIApplication *) Application {7NSLog (@"called when the app receives a memory warning");8 }9 Ten- (void) Applicationdidenterbackground: (UIApplication *) Application { OneNSLog (@"called when the app enters the background"); A } -  -- (void) Applicationwillresignactive: (UIApplication *) Application { theNSLog (@"app will be suspended"); - } -  -- (void) Applicationwillenterforeground: (UIApplication *) Application { +NSLog (@"app back to front desk"); - } +  A- (void) Applicationdidbecomeactive: (UIApplication *) Application { atNSLog (@"after the app is activated"); - } -  -- (void) Applicationwillterminate: (UIApplication *) Application { -NSLog (@"app will close"); - } in  

(1) The General app operation triggers the delegate agent to monitor the event flow: (2) The entire app startup process: The Uiapplicationmain function called in the 2.main function
 1  int  Main ( int  argc, char  *  argv[]) { 2   @autoreleasepool { 3  return  Uiapplicationmain (argc, argv, Nil, nsstringfromclass ([Appdel Egate class   4   5  }
function definition: Uikit_extern int uiapplicationmain (int argc, char *argv[], nsstring *principalclassname, NSString * Delegateclassname); (1) Principalclassname A.application class name, must be the class name of UIApplication or its subclasses B. If nil, the default is uiapplication C.uiapplicationmain letter The principalclassname creates a UIApplication object (2) Delegateclassname A.delegate class name based on the Uiapplicationdelegate protocol B.UIApplic The Ationmain function creates a delegate based on Delegateclassname and assigns it to the delegate attribute of UIApplication (3) into the main Runloop event loop, Use delegate to listen for events (4) The program exits normally, and the Uiapplicationmain function returns

[iOS base Control-6.10.6] Uiapplicationdelegate

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.