Types of View Controllers in iPhone SDK

Types of View Controllers


Most iPhone 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 the express purpose of presenting some content on the screen. Most iPhone applications present data using several distinct screens, each of which offers a different way of viewing data. For example, you might have one screen that presents a list of items in a a table and another screen 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 data for each distinct type of screen.

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 and tab bar controllers are both examples of container view controllers. Typically, you do not define container view controllers yourself. Instead, you use the container view controllers provided by the system as is. This is because each container view controller provides a complete implementation of a specific type of interface.

A modal view controller is any view controller (container or custom) that is presented in a specific way by another view controller. Modal view controllers define a specific navigational relationship in your application. The most common reason to present a view controller modally is so that you can prompt the user to input some data. For example, you might present a view controller modally to have the user fill in a form or select an option from a picker interface. However, there are other uses for modal view controllers that are described in more detail in “Modal View Controllers.”






Figure shows the view controller classes available in the UIKit framework along with some of the key classes used in conjunction with view controllers. These additional classes are often used internally by view controller objects to implement special types of interfaces. For example, the UITabBarController object manages a UITabBar object, which actually displays the tabs associated with the tab bar interface. Other frameworks may also define additional view controller objects in order to present specific types of interfaces.



No comments:

 
Top Blogs