Common use methods of UIApplication sharedapplication

Source: Internet
Author: User

Here are some of the features of this class:
1. Set the number icon on the icon

Set the digital icon on the main interface icon, introduced in 2.0, the default is 0

[Uiapplicationsharedapplication].applicationiconbadgenumber = 4;
2. Whether the Redo,undo action is supported when setting the shake gesture

Shake gesture, whether the redo undo operation is supported.

3.0 after introduction, default Yes


[Uiapplicationsharedapplication].applicationsupportsshaketoedit =yes;


3. Judging the state of the program operation

Determine the state of the program's operation and introduce it after 2.0

/*

Uiapplicationstateactive,

Uiapplicationstateinactive,

Uiapplicationstatebackground

*/

if ([Uiapplicationsharedapplication].applicationstate ==uiapplicationstateinactive) {

NSLog (@ "program in Operation State");

}
4. Prevent the screen from darkening into hibernation

Prevent screen from darkening, use cautiously, default to No 2.0

[Uiapplicationsharedapplication].idletimerdisabled =yes;

(Use this feature sparingly because it is very power-hungry)
5. Show Networking Status

Show Networking Tags 2.0
[Uiapplicationsharedapplication].networkactivityindicatorvisible =yes;


6. Show an address on the map

nsstring* addresstext [email protected] "1 Infinite Loop, Cupertino, CA 95014";

URL encode the spaces

Addresstext = [addresstextstringbyaddingpercentescapesusingencoding:nsasciistringencoding];

nsstring* Urltext = [nsstringstringwithformat:@ "http://maps.google.com/maps?q=%@", Addresstext];

[[Uiapplicationsharedapplication]openurl:[nsurlurlwithstring:urltext]];


7. Send an email

NSString *recipients [email protected] "Mailto:[email protected][email protected],[email Protected]&subject=hello From california! ";

NSString *body [email protected] "&body=it is raining in sunny california!";

NSString *email = [nsstringstringwithformat:@ "%@%@", recipients, body];

email = [Emailstringbyaddingpercentescapesusingencoding:nsutf8stringencoding];

[[Uiapplicationsharedapplication]openurl:[nsurlurlwithstring:email]];
8. Call a number

Call Google 411
[[uiapplicationsharedapplication]openurl:[nsurlurlwithstring:@ "tel://8004664411"]];


9. Send SMS

Text to Google SMS
[[uiapplicationsharedapplication]openurl:[nsurlurlwithstring:@ "sms://466453"]];


10. Open a URL

Lanuch any IPhone developers fav site
[[uiapplicationsharedapplication]openurl:[nsurlurlwithstring:@ "http://itunesconnect.apple.com"]];


Common use methods of UIApplication sharedapplication

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.