Self-learning iOS development small feature VI: uiapplication

Source: Internet
Author: User

First, UIApplication

1. Brief introduction

(1) The UIApplication object is a symbol of the application, and a UIApplication object represents an application.

(2) Each application has its own UIApplication object, and is a singleton, if you try to create a new UIApplication object in the program, then the error prompt.

(3) This singleton object can be obtained by [UIApplication Sharedapplication].

(4) The first object created after an iOS program is started is the UIApplication object, and there is only one.

(5) Using UIApplication object, can carry on some application level operation.

2. Code examples for application-level operations

(1) Set the red reminder number in the upper right corner of the application icon (obsessive-compulsive nightmare)

 1  uiapplication *app = [uiapplication Sharedapplication];     2   Create notification  3  uiusernotificationsettings *setting =  [Uiusernotificationsettings Settingsfortypes:uiusernotificationtypebadge Categories:nil];     4   Registration notification  5   [app Registerusernotificationsettings:setting];     6   Set AppIcon reminder number  7  app.applicationiconbadgenumber = 200 ; 

(2) can open Web page (drag a button in storyboard, listen button)

1 -(ibaction) Btnclick: (ID) sender {2//     open page 3     uiapplication *app = [uiapplication sharedapplication]; 4     Nsurl *url = [Nsurl urlwithstring:@ "https://www.baidu.com"]; 5     [app Openurl:url]; 6 }

(3) can display the network status (has been in the circles)

1     UIApplication *app = [uiapplication sharedapplication]; 2 //     set up Networking status 3     app.networkactivityindicatorvisible = YES;

(4) Set the status bar color (not see how much change, but it does have this method)

1 -(uistatusbarstyle) preferredstatusbarstyle2{3//     set to White 4     return uistatusbarstylelightcontent; 5     // default is black 6     return Uistatusbarstyledefault; 7 }

(5) You can hide the status bar

But I tried the code did not succeed (-(BOOL) Prefersstatusbarhidden, etc. including the other two ways) but add the status bar is initially hidden Yes in info.plist.

(6) is said to be able to call, send text messages, e-mail and many other features, I tried the next online to the code, have not succeeded, have to know how to share under.

Self-learning iOS development small feature VI: 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.