Introduction and application of UIApplication

Source: Internet
Author: User

UIApplication is a system singleton that has only one piece of memory, no matter when the program is created. Its application is: Set the mobile phone desktop app icon on the number of messages displayed on the alert, you can monitor the network status, call, open the page, control status bar and so on.

1,app a message reminder number.

Can do this: [UIApplication sharedapplication].applicationiconbadgenumber = 10;

Note: Set this to require app registration push notification Service: [UIApplication sharedapplication]registernotificationsettings:[uiusernotifications Settingfortype:uiusernotificationtypebadge Categories:nil];

2. Set the networking status.

[UIApplication sharedapplication]. networkactivityindicatorvisible = YES; Set this, when the program is networked, the status bar will have a chrysanthemum in turn.

3, you can open the Web page (call the same)

[[UIApplication sharedapplication] openurl:[nsurl urlwithstring:@ "http://www.baidu.com"]; Can be placed in the button click Method, when clicked on the button, directly open the specified page.

4. Control the status bar to hide or change the style.

First note: After iOS7, the status bar is managed by the controller by default, that is, the controller automatically calls Preferstatusbarhidden this method to determine whether the current controller's status bar is hidden. But each controller needs to be set up, which is more troublesome. Can be handed to uiapplication management, need to add field in Info.plist View Controller based status bar appearance set to No, indicating that the status bar does not need to be controlled by the controller. Then you can use UIApplication to manage the status bar. As follows:

[[UIApplication sharedapplication] setstatusbarhidden:yes];

Introduction and application of UIApplication

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.