IOS Uikit:viewcontroller Hierarchy

Source: Internet
Author: User

Viewcontroller is an important part of iOS applications and is an important bridge between application data and views. And the application has at least one view controller. Each view controller object is responsible for and manages a view object called the root view, which organizes and manages a hierarchy of views rooted in root view.

Figure 11

There are two types of view controllers that you can divide:

1) Content: Used to manage the decentralized view controls in the view, which are the primary entities in the app.

2) Container: As a container for storing and managing other view controllers for navigation and representation.

1 Root View Controller

The Root View Controller (abbreviated as RVC) is the backbone of all view controllers, and window uses RVC to populate its content view, which is RVC as a child view of the window, and the app puts all the visual components in the RVC. Or the RVC child view, shown in 12.

Figure The root View controller

There is a Rootviewcontroller property in the UIWindow object that describes the root VC object. If the VC is configured via storyboards, then Uikit automatically sets the Rootviewcontroller property of the UIWindow, and if the window is created through the program, Then you need to manually set the window's Rootviewcontroller property.

2 Container View Controllers

Container View Controllers (CVC) can assemble discrete views or components into complex apps that can be reused for these components or views. Uikit defines some CVC containers, with Uinavigationcontroller, Uisplitviewcontroller and Uipageviewcontroller.

CVC manages the spatial layout and location of the child view controller and is often used as the root view controller, as shown in Figure 13. Of course, CVC can be used as the parent container for any view controller, including other CVC.

Figure A Container acting as the root view controller

3 presented View Controllers

Presented View Controllers (abbreviated as PVC) is often used to replace the currently displayed view controller, which will be the new display of the PVC. When present a new view controller as the display, Uikit creates a relationship between the presenting view controller and the presented view Controller, as shown in 14.

Figure presented view controllers

When present a new view controller, Uikit will look for a container view controllers that can provide the appropriate context, most of which is to choose container View controllers from the nearest Sometimes it is necessary for the user to manually specify container view controllers as the context provided by this present.

15, describes a present operation that involves container view controllers, which present a green view when the screen shows yellow is the view. Instead of the controller associated with the yellow view as the presenting view controller, the navigation controller is used as the presenting view controller.

Figure A container and a presented view controller

IOS Uikit:viewcontroller Hierarchy

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.