[Basic iOS control and basic ios Control

Source: Internet
Author: User

[Basic iOS control and basic ios Control
A. Concept1. mobile apps are vulnerable to interference from other systems and software events, such as mains and screen lock. when the app is disturbed, UIApplication will notify delegate to process the interference event as a proxy. 3. events that delegate can handle (1) app declaration cycle (START and close) (2) system events (incoming calls) (3) Emergencies (memory warning)B. UseA condition called delegate: The project that complies with the UIApplicationDelegate protocol is automatically created at the beginning: AppDelegate 1-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions {2 NSLog (@ "called upon app startup"); 3 return YES; 4} 5 6-(void) applicationDidReceiveMemoryWarning :( UIApplication *) application {7 NSLog (@ "called when the app receives a memory warning"); 8} 9 10-(void) applicationDidEnterBackground :( UIApplication *) application {11 NSLog (@ "called when the app enters the background"); 12} 13 14-(void) applicationWillResignActive :( UIApplication *) application {15 NSLog (@ "app to be suspended"); 16} 17 18-(void) applicationWillEnterForeground :( UIApplication *) application {19 NSLog (@ "app back to front-end "); 20} 21 22-(void) applicationDidBecomeActive :( UIApplication *) application {23 NSLog (@ "app activated"); 24} 25 26-(void) applicationWillTerminate :( UIApplication *) application {27 NSLog (@ "app will be closed"); 28} 29

 

(1) process of delegate agent listening event triggered by General app operations: 1 int main (int argc, char * argv []) {2 @ autoreleasepool {3 return UIApplicationMain (argc, argv, nil, NSStringFromClass ([AppDelegate class]); 4} 5}Function Syntax: UIKIT_EXTERN int UIApplicationMain (int argc, char * argv [], NSString * principalClassName, NSString * delegateClassName); (1) principalClassName. application class name. It must be the class name B of the UIApplication or its subclass. if it is nil, the default value is UIApplication c. the UIApplicationMain function creates a UIApplication object based on principalClassName (2) delegateClassName. the delegate class name, which must comply with the UIApplicationDelegate Protocol B. the UIApplicationMain function creates a delegate based on delegateClassName and assigns it to the delegate attribute of the UIApplication (3). It enters the Main Runloop event loop and uses delegate to listen to the event (4). The program Exits normally, the UIApplicationMain function returns

Related Article

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.