Those in UIWindow and those in UIWindow

Source: Internet
Author: User

Those in UIWindow and those in UIWindow

UIView is the base class of the view, UIViewController is the base class of the View Controller, and UIResponder is an object that can respond to touch events on the screen;

1. UIWindow is a special type of UIView. Generally, there is only one UIWindow in a program. However, you can manually create multiple uiwindows and add them to the program. UIWindow mainly plays three roles in the program:

1. As a container, including all views to be displayed by the app

2. Send the touch message to the view and other objects in the program.

3. Work with UIViewController to facilitate device Rotation

2. You can add the view to the UIWindow in two ways:

1. addSubview

Directly add the view to the window through the addSubview method. The program is responsible for maintaining the view lifecycle and refreshing, but does not ignore the ViewController corresponding to the view, therefore, after adding the view to the window, we need to maintain the validity of the ViewController corresponding to the view and cannot release it too early.

2. rootViewController

A Traversal method of UIWindow in rootViewController. By setting this attribute to add the ViewController corresponding to the view, UIWindow automatically adds its view to the current window, maintains the lifecycle of ViewController and view to prevent premature release.

 

The main window (key window) accepts specific events

A window is considered as the main window when it can accept keyboard and non-touch events. The Touch event is shipped to the window where the touch occurs, and the event without the corresponding coordinate value is shipped to the main window. At the same time, only one window is the main window.

Most of the time, the application window is the main window. Because iOS uses a separate window to display the warning view and input accessory view, these windows can also be the main window. For example, if a lecture view or an input attachment view has a text box in which the user is currently entering the text box, the window containing the input view is the main window.

Most application windows are at the same level.

When you create a new window for an application, the UIVindow class automatically assigns it a level called normal window level ), this level is suitable for the window that displays application-related content. This level can be set through the windowLevel attribute, which represents the position of the window relative to other windows in the Z axis. You can display the application-related windows at other levels, but this is not required.

In addition to the window for displaying application-related content, there are also some high-level windows that display information that needs to be suspended on the application content. For example, system status bar and warning.

For more information about keyWindow and WindowLevel, see: http://www.cnblogs.com/smileEvday/archive/2012/11/16/UIWindow.html

Related Article

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.