View Controllers In the ModelViewController MVC design pattern

  • Slides: 6
Download presentation
View Controllers • In the Model-View-Controller (MVC) design pattern, a controller object provides the

View Controllers • In the Model-View-Controller (MVC) design pattern, a controller object provides the custom logic needed to bridge the application’s data to the views and other visual entities used to present that data to the user. • In i. OS applications, a view controller is a specific type of controller object that you use to present and manage a set of views. View controller objects are descendants of the UIView. Controller class, which is defined in the UIKit framework. • Applications running on i. OS–based devices have a limited amount of screen space for displaying content and therefore must be creative in how they present information to the user. Applications that have lots of content may have to distribute that content across multiple screens or show and hide different parts of content at different times. View controller objects provide the infrastructure for managing your content-related views and for coordinating the showing and hiding of them.

Benefits of View Controllers • There are many reasons to use view controllers in

Benefits of View Controllers • There are many reasons to use view controllers in your application and very few reasons to avoid them. • View controllers make it easier for you to implement many of the standard interface behaviours found in i. OS applications. • They provide default behaviour that you can use as is or customize when needed. • They also provide a convenient way to organize your application’s user interface and content.

Types of View Controllers • There are two types of view controllers 1. Custom

Types of View Controllers • There are two types of view controllers 1. Custom View Controller 2. Container View Controller Most i. OS applications have at least one view controller and some have several. Broadly speaking, view controllers are divided into three general categories that reflect the role the view controller plays in your application.

 • A Custom View Controller is a controller object that you define for

• A Custom View Controller is a controller object that you define for the express purpose of presenting some content on the screen. Most i. OS applications present data using several distinct sets of views, each of which handles the presentation of your data in a specific way. For example, you might have a set of views that presents a list of items in a table and another set that displays the details for a single item in that list. The corresponding architecture for such an application would involve the creation of separate view controllers to manage the marshaling and display of each set of views.

 • A Container View Controller is a specific type of view controller object

• A Container View Controller is a specific type of view controller object that manages other view controllers and defines the navigational relationships among them. Navigation, tab bar, and split view controllers are all examples of container view controllers. You do not define container view controllers yourself. Instead, you use the container view controllers provided by the system as is.