"UIKit" appdelegate detailed and partial uiapplication calls

Source: Internet
Author: User
Tags set background

"UIKit" appdelegate

Called after the application has finished launching (only once, only when the program is opened for the first time)
-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions{    Create a UIWindow    cgrect rect = [[UIScreen mainscreen] bounds];    Self.window = [[UIWindow alloc] initwithframe:rect];    Set background color    Self.window.backgroundColor = [Uicolorredcolor];    Initialize the first controller    self.viewcontroller = [[Viewcontroller alloc] initwithnibname:@ "Viewcontroller" bundle:nil];    Set the window's root controller     self.window.rootViewController = Self.viewcontroller;    When the window UIWindow display, it will add the Rootviewcontrooler view to the UIWindow above//make the window become the main window and visible     [self.windowmakekeyandvisible];   Returnyes;}


Called when the app loses focus (inactive): When the application is going to be inactive, during which time the application does not receive messages or events, such as a call
-(void) Applicationwillresignactive: (uiapplication *) application

Called when the app is in the background: Called when the program is pushed to the background. So to set the background to continue running, you can set it in this function
-(void) Applicationdidenterbackground: (uiapplication *) application

Called when the app enters the foreground: when the program is going back to the foreground from the background, this is exactly the opposite of the method above.
-(void) Applicationwillenterforeground: (uiapplication *) application

Called when the app gets focus (activated): When the application is in Active state execution
-(void) Applicationdidbecomeactive: (uiapplication *) application

When the program is about to exit is called, it is usually used to save the data and some cleanup work before exiting. This needs to set the key value of the uiapplicationexitsonsuspend.
-  (void) Applicationwillterminate: (uiapplication *) application

Description: The iphone device has only limited memory, and if the application is assigned too much memory the operating system will terminate the application's operation, this method will be executed before termination, usually can be done in the memory cleanup work to prevent the program from being terminated
-  (void) applicationdidreceivememorywarning: (uiapplication *) application

Description: Executes when the system time has changed
-(void) Applicationsignificanttimechange: (uiapplication*) application

Description: Executes when the program is loaded
-(void) applicationdidfinishlaunching: (uiapplication*) application

Description: Executes when the StatusBar box is going to change
-(void) application: (uiapplication) Application Willchangestatusbarframe: (cgrect) Newstatusbarframe

Description: Executed when the StatusBar box direction is going to change
-(void) application: (uiapplication*) Application willchangestatusbarorientation: (uiinterfaceorientation) Newstatusbarorientationduration: (nstimeinterval) duration

Description: When executing via URL
-(BOOL) Application: (uiapplication*) Application Handleopenurl: (nsurl*) URL

Description: Executes when the StatusBar box direction changes
-(void) application: (uiapplication*) Application didchangestatusbarorientation: (uiinterfaceorientation) Oldstatusbarorientation

Description: Executes when the StatusBar box changes
-(void) application: (uiapplication*) Application Didchangesetstatusbarframe: (cgrect) Oldstatusbarframe




Turn:
1. Determine the type of device ipad or iphone, you can define a macro in main to record
#define IS_IPAD  ([[Uidevice Currentdevice] Respondstoselector: @selector (USERINTERFACEIDIOM)] &&[[ Uidevice Currentdevice] userinterfaceidion] = = Uiuserinterfaceidiompad)
2. Call your own app    
Call Email
     
   
Call System telephone Phone
     [[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "tel://88888888"];

Call SMS
     [[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "sms://888588"];  

Call your own browser safari
     [[UIApplication sharedapplication] Openurl:[nsurl urlwithstring:@ "http://url"];      Also: itms://can open Mobilestore.app            audio-player-event://can open ipod            audio-player-event://?uicmd= Show-purchased-playlist can open ipod playlist            video-player-event://can open video in ipod

3. No lock screen
    UIApplication *app = [uiapplication sharedapplication];    app.idletimerdisabled = YES;

4. Set the number on the icon
 [[UIApplication sharedapplication] setapplicationiconbadgenumber:0]; 

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.