UIApplication and UIWindow

Source: Internet
Author: User

Info.plist file

This file for the project to do some run-time configuration, very important, can not be deleted.

Common Properties

PCH file

The project's suportting Files folder has a "project name-prefix.pch" file and a header file

The contents of the PCH file can be shared and accessed by all other source files in the project

In general, some global macros are defined in the PCH file

Add the following preprocessing directives in the PCH file, and then use the log (...) in your project. To output the log information, you can remove the NSLog statement at one time when the application is published (in debug mode, debug is defined)

    

UIApplication

UIApplication objects are symbols of the application

Each application has its own UIApplication object, and they are all single-instance

This singleton object can be obtained by [UIApplication Sharedapplication]

The first object created after an iOS program is started is a UIApplication object

With UIApplication objects, you can handle some application-level operations

Common Properties of UIApplication

Status bar

Starting with iOS7, there are two ways to control the status bar

1. Through Uiviewcontroller management (each uiviewcontroller can have their own different status bar)

2. UIApplication Management (the status bar of an application is managed by him uniformly)

By default, the status bar is managed by Uiviewcontroller, and Uiviewcontroller makes it easy to manage the style and visibility of the status bar by implementing the following methods.

    

    

If you use UIApplication to manage the status bar, first modify the Info.plist settings

     

UIApplication has a very powerful function (OpenURL:) method

    

    

UIApplication and delegate

All mobile operating systems have a fatal disadvantage and the app is vulnerable to interference. For example, a phone call or a lock screen will cause the app to end up in the background.

When the app is disturbed, some system events are generated, which is the delegate object that UIApplication notifies it, allowing delegate agents to handle these system events

    

    

Every time you create a new project, there is a appdelegate word class, he is the agent of the Uiappliaction object, he is the default compliance <UIApplicationDelegate> protocol

iOS program start-up process

      

Uiapplicationmain

A uiapplicationmain function is executed in the main function.

      

The Uiapplicationmain function creates a UIApplication object based on Principalclassname and creates a delegate object from Delegatedelegateclassname. and assigns the delegate object to the delegate property in the UIApplication object

The application's main Runloop (the event loop) is then created, and the event is processed (the application:didfinishlaunchingwithoptions of the delegate object is called first after the program is completed: method)

The Uiapplicationmain function returns when the program exits normally

UIWindow

UIWindow is a special kind of uiview that usually has a uiwindow in an app.

After the iOS program is started, the first view space created is UIWindow, the controller's view is created, the controller's view is added to the UIWindow, and the controller's view is displayed on the screen.

The iOS program can be displayed on the screen entirely because it has UIWindow

If there is no uiwindow, we can't see any interface

      

UIWindow's acquisition

UIApplication and UIWindow

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.