본문 바로가기

Programming/Udacity Nano Degree - iOS Developer

View Controller

An object that manages a view hierarchy for your UIKit app.

Declaration

class UIViewController : UIResponder

Overview

The UIViewController class defines the shared behavior that is common to all view controllers. You rarely create instances of the UIViewController class directly. Instead, you subclass UIViewController and add the methods and properties needed to manage the view controller's view hierarchy. 

A view controller’s main responsibilities include the following:

  • Updating the contents of the views, usually in response to changes to the underlying data.

  • Responding to user interactions with views. 

  • Resizing views and managing the layout of the overall interface.

  • Coordinating with other objects—including other view controllers—in your app.

A view controller is tightly bound to the views it manages and takes part in handling events in its view hierarchy. Specifically, view controllers are UIResponder objects and are inserted into the responder chain between the view controller’s root view and that view’s superview, which typically belongs to a different view controller. If none of the view controller’s views handle an event, the view controller has the option of handling the event or passing it along to the superview.

View controllers are rarely used in isolation. Instead, you often use multiple view controllers, each of which owns a portion of your app’s user interface. For example, one view controller might display a table of items while a different view controller displays the selected item from that table. Usually, only the views from one view controller are visible at a time. A view controller may present a different view controller to display a new set of views, or it may act as a container for other view controllers’ content and animate views however it wants.

 

 

Apple Developer Documentation

 

developer.apple.com