zoukankan      html  css  js  c++  java
  • The Role of View Controllers

    https://developer.apple.com/library/content/featuredarticles/ViewControllerPGforiPhoneOS/index.html#//apple_ref/doc/uid/TP40007457-CH2-SW1

    View controllers are the foundation of your app’s internal structure. Every app has at least one view controller, and most apps have several. Each view controller manages a portion of your app’s user interface as well as the interactions between that interface and the underlying data. View controllers also facilitate transitions between different parts of your user interface. 

    Because they play such an important role in your app, view controllers are at the center of almost everything you do. The UIViewController class defines the methods and properties for managing your views, handling events, transitioning from one view controller to another, and coordinating with other parts of your app. You subclass UIViewController (or one of its subclasses) and add the custom code you need to implement your app’s behavior.

    There are two types of view controllers:

    • Content view controllers manage a discrete piece of your app’s content and are the main type of view controller that you create.

    • Container view controllers collect information from other view controllers (known as child view controllers) and present it in a way that facilitates navigation or presents the content of those view controllers differently. 

    Most apps are a mixture of both types of view controllers.

    View Management

    The most important role of a view controller is to manage a hierarchy of views. Every view controller has a single root view that encloses all of the view controller’s content. To that root view, you add the views you need to display your content. Figure 1-1 illustrates the built-in relationship between the view controller and its views. The view controller always has a reference to its root view and each view has strong references to its subviews. 

    Figure 1-1Relationship between a view controller and its viewsimage: ../Art/VCPG_ControllerHierarchy_fig_1-1_2x.png

    NOTE

    It is common practice to use outlets to access other views in your view controller’s view hierarchy. Because a view controller manages the content of all its views, outlets let you store references to the views that you need. The outlets themselves are connected to the actual view objects automatically when the views are loaded from the storyboard. 

    A content view controller manages all of its views by itself. A container view controller manages its own views plus the root views from one or more of its child view controllers. The container does not manage the content of its children. It manages only the root view, sizing and placing it according to the container’s design. Figure 1-2 illustrates the relationship between a split view controller and its children. The split view controller manages the overall size and position of its child views, but the child view controllers manage the actual contents of those views. 

    Figure 1-2View controllers can manage content from other view controllersimage: ../Art/VCPG_ContainerViewController_fig_1-2_2x.png

    For information about managing your view controller’s views, see Managing View Layout

  • 相关阅读:
    如何找bug
    信号量
    带组装的测试
    Oracle的一些操作
    NPOI的操作
    初次认识 C# win32 api
    C# 通过Selecnuim WebDriver操作非IE浏览器
    DevExpress.chartControt画趋势图
    DevExpress.chartContro控件保存图片和打印图片
    SqlServer基础复习
  • 原文地址:https://www.cnblogs.com/feng9exe/p/7059475.html
Copyright © 2011-2022 走看看