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

  • 相关阅读:
    使用Publish Over SSH插件实现远程自动部署
    Certificates does not conform to algorithm constraints
    在 Linux 命令行脚本中执行 sudo 时自动输入密码
    pig学习
    Attention-based Model
    kesci---2019大数据挑战赛预选赛---情感分析
    计算广告(1)---广告技术概览
    Hadoop 使用小命令(2)
    shell学习(2)----常用语法
    docker入门
  • 原文地址:https://www.cnblogs.com/feng9exe/p/7059475.html
Copyright © 2011-2022 走看看