Views and View Controllers
In iOS development, the view controllers are the foundation of the Application's internal structure. The View Controller is the parent of all the views present on a storyboard. Each application has at least one ViewController. It facilitates the transition between various parts of the user interface.
The UIViewController is the parent class of all the ViewControllers. It defines all the methods and properties for managing our views. This class also manages the events and transitions from one view controller to another. It also coordinates between the different parts of the application.
Types of ViewControllers
There are two types of ViewControllers:
Most iOS applications are the mixture of both, Content ViewController and Container ViewController.
In iOS development, the ViewController manages the hierarchy of views. As shown in the below image, each ViewController contains a RootView which contains all the content of the view controller. All the custom views needed to maintain an iOS application is added to the root view to display the content. The following figure shows the relationship between ViewController, RootView, and its subviews. Each sub view is referred by a Super View which incorporates a chain of Views where a RootView acts as the Parent View of all the views present in the View Controllers.
In iOS Development, a View Controller is responsible for displaying the data of our iOS application on the screen. It acts as an interface between its Views (created by the developer) and the application data. Each ViewController in the Storyboard is assigned a Class that inherits the UIViewController class.
All of the properties and methods defined in the UIViewController is present in the class that we assign to the ViewController. However, for the development of our application, we need to define our properties and methods in the ViewController class. It helps us manage the visual representation of our application.