Each app has and has only one UIApplication object, which is obtained by invoking the Uiapplicationmain method when the program starts. can be obtained by sharedapplication method.
The primary task of the UIApplication object is to handle the processing path of the user event, such as distributing a uievent to another object to handle. The UIApplication object holds numerous UIWindow objects, so you can organize your app's presentation. UIApplication objects can also handle resources, such as through OpenURL: Opening a mailbox client or setting up an interface.
Get UIApplication Object
[UIApplication Sharedapplication]
Get Uiapplicationdelegate Object
[[UIApplication Sharedapplication] delegate]
Get UIWindow Object
[[UIApplication sharedapplication] windows]; UIWindow array [[UIApplication sharedapplication] Keywindow]; The UIWindow object in the UIWindow array that last called the Makekeyandvisible method
Control and Process Uievent
-(void) Touchesbegan: (Nsset *) touches withevent: (uievent *) event{//distribute an event to another object to handle [[uiapplication Sharedapplication] SendAction: @selector (action:forevent:) to:[customhandler Sharedcustomhandler] From:self forEvent : event];}
[[UIApplication sharedapplication] beginignoringinteractionevents]; Start Ignoring event//... Middle call animation and other operations [[UIApplication Sharedapplication] endignoringinteractionevents]; End Ignore Event
[UIApplication sharedapplication].applicationsupportsshaketoedit = YES; Does shaking have undo or redo action
Open a URL resource
[[UIApplication sharedapplication] Openurl:[nsurl urlwithstring:uiapplicationopensettingsurlstring]];//Open the Settings screen
Configuring notification Settings
Uiusernotificationtype types = Uiusernotificationtypebadge | Uiusernotificationtypesound | Uiusernotificationtypealert; Uiusernotificationsettings *mysettings = [uiusernotificationsettings settingsfortypes:types categories: NIL]; [[UIApplication sharedapplication] registerusernotificationsettings:mysettings]; Registering Remote push notifications
[[uiapplication Sharedapplication] registerforremotenotifications];//registration [[UIApplication sharedApplication] unregisterforremotenotifications];//logoff
NSDate *date = [NSDate datewithtimeintervalsincenow:10]; Uilocalnotification *localnotif = [[Uilocalnotification alloc] init]; Localnotif.firedate = date; Time Localnotif.timezone = [Nstimezone localtimezone]; Time zone localnotif.repeatinterval = Nscalendarunitminute; Interval localnotif.soundname = Uilocalnotificationdefaultsoundname; Sound localnotif.alertbody = @ "Local Test"; Notification content Localnotif.applicationiconbadgenumber = 1; Digital indicator Localnotif.userinfo = @{@ "key": @ "Test"}; info [[uiapplication sharedapplication] schedulelocalnotification:localnotif]; Registration Notification
[[UIApplication sharedapplication] presentlocalnotificationnow:localnotif]; immediately notify [[UIApplication sharedapplication] cancelalllocalnotifications];//Cancel all Notifications [[UIApplication Sharedapplication] cancellocalnotification:localnotif]; Cancel a specific notification nsarray *arr = [[UIApplication sharedapplication] scheduledlocalnotifications]; All the Notifications
Background Run related
[[UIApplication sharedapplication] applicationstate]; App status [[[UIApplication sharedapplication] setminimumbackgroundfetchinterval:3600];//Set Background run time Nstimeinterval remaintime = [[UIApplication sharedapplication] backgroundtimeremaining]; App background run time NSLog (@ "remaintime =%f", remaintime); int state = [[UIApplication sharedapplication] backgroundrefreshstatus]; The status of the background refresh NSLog (@ "state =%d"); [[UIApplication sharedapplication] beginbackgroundtaskwithname:@ "TaskOne" expirationhandler:^{ }]; [[UIApplication sharedapplication] beginbackgroundtaskwithexpirationhandler:^{ }]; [[UIApplication sharedapplication] endbackgroundtask:1];
Remote control-related
[[UIApplication sharedapplication] beginreceivingremotecontrolevents]; [[UIApplication sharedapplication] endreceivingremotecontrolevents];
Idle Timer of the system
[UIApplication sharedapplication].idletimerdisabled = YES; Don't let your phone sleep
App Style
Hide the status bar [[UIApplication sharedapplication] setstatusbarhidden:yes]; [[UIApplication sharedapplication] Setstatusbarhidden:yes withanimation:uistatusbaranimationslide]; Set the style of the status bar [[UIApplication sharedapplication] setstatusbarstyle:uistatusbarstyledefault]; [[UIApplication sharedapplication] statusbarstyle]; Frame of the status bar [[UIApplication sharedapplication] statusbarframe]; Whether the network is visible [[UIApplication sharedapplication] isnetworkactivityindicatorvisible]; Badge number [UIApplication sharedapplication].applicationiconbadgenumber = 2; The direction of the screen [[UIApplication sharedapplication] userinterfacelayoutdirection];
Set the orientation of the status bar
[[UIApplication sharedapplication] Setstatusbarorientation:uiinterfaceorientationlandscapeleft Animated:YES];
Data type
Uibackgroundtaskidentifier:int
typedef enum:nsuinteger { Uiremotenotificationtypenone = 0, uiremotenotificationtypebadge = 1 < < 0, uiremotenotificationtypesound = 1 << 1, uiremotenotificationtypealert = 1 << 2, uiremotenotificationtypenewsstandcontentavailability = 1 << 3} Uiremotenotificationtype;
typedef Enum:nsinteger { Uistatusbarstyledefault, uistatusbarstylelightcontent, Uistatusbarstyleblacktranslucent, uistatusbarstyleblackopaque} uistatusbarstyle;
typedef Enum:nsinteger { Uistatusbaranimationnone, Uistatusbaranimationfade, Uistatusbaranimationslide,} uistatusbaranimation;
typedef enum:nsinteger { uiapplicationstateactive, uiapplicationstateinactive, Uiapplicationstatebackground} uiapplicationstate;
Const Uibackgroundtaskidentifier uibackgroundtaskinvalid; const Nstimeinterval uiminimumkeepalivetimeout;
typedef enum:nsuinteger { uibackgroundfetchresultnewdata, uibackgroundfetchresultnodata, uibackgroundfetchresultfailed} Uibackgroundfetchresult;
Const NSTIMEINTERVAL uiapplicationbackgroundfetchintervalminimum; Const Nstimeinterval Uiapplicationbackgroundfetchintervalnever;
typedef enum:nsuinteger { uibackgroundrefreshstatusrestricted, uibackgroundrefreshstatusdenied, uibackgroundrefreshstatusavailable} Uibackgroundrefreshstatus;
typedef enum:nsinteger { Uiinterfaceorientationunknown = Uideviceorientationunknown, Uiinterfaceorientationportrait = uideviceorientationportrait, uiinterfaceorientationportraitupsidedown = Uideviceorientationportraitupsidedown, Uiinterfaceorientationlandscapeleft = uideviceorientationlandscaperight, Uiinterfaceorientationlandscaperight = uideviceorientationlandscapeleft} uiinterfaceorientation;
typedef enum:nsinteger { uiuserinterfacelayoutdirectionlefttoright, Uiuserinterfacelayoutdirectionrighttoleft,} uiuserinterfacelayoutdirection;
NSString *const uiapplicationopensettingsurlstring;
NSString *const Uiapplicationstatusbarorientationuserinfokey; NSString *const Uiapplicationstatusbarframeuserinfokey;
NSString *const Uicontentsizecategoryextrasmall; NSString *const Uicontentsizecategorysmall; NSString *const Uicontentsizecategorymedium; NSString *const Uicontentsizecategorylarge; NSString *const Uicontentsizecategoryextralarge; NSString *const Uicontentsizecategoryextraextralarge; NSString *const Uicontentsizecategoryextraextraextralarge;
NSString *const Uicontentsizecategoryaccessibilitymedium; NSString *const Uicontentsizecategoryaccessibilitylarge; NSString *const Uicontentsizecategoryaccessibilityextralarge; NSString *const Uicontentsizecategoryaccessibilityextraextralarge; NSString *const Uicontentsizecategoryaccessibilityextraextraextralarge;
NSString *const uiapplicationinvalidinterfaceorientationexception;
Notice
Uiapplicationbackgroundrefreshstatusdidchangenotificationuiapplicationdidbecomeactivenotificationuiapplicationdidchangest Atusbarframenotificationuiapplicationdidchangestatusbarorientationnotificationuiapplicationdidenterbackgroundnotification Uiapplicationdidfinishlaunchingnotificationuiapplicationdidreceivememorywarningnotificationuiapplicationprotecteddatadidb Ecomeavailableuiapplicationprotecteddatawillbecomeunavailableuiapplicationsignificanttimechangenotificationuiapplicationu Serdidtakescreenshotnotificationuiapplicationwillchangestatusbarorientationnotificationuiapplicationwillchangestatusbarfr Amenotificationuiapplicationwillenterforegroundnotificationuiapplicationwillresignactivenotificationuiapplicationwillterm Inatenotificationuicontentsizecategorydidchangenotification
UIApplication detailed re-interpretation-preparation