Mobile Development

View Controllers

Apple includes a variety of View Controllers which organize your views and provide a controller class for delegates and other interactions.


UIViewController is the building block for user interfaces. You will typically subclass UIViewController in the development of your own view controllers.

The UIViewController class provides the fundamental view-management model for all iOS apps

View Controller Life Cycle

UIViewController provides a number of methods that you can override at various points of the view controller's life cycle.


Common methods to overide

Depending on what you want to accomplish, the following methods can be overridden. These are all optional overrides.

Method name Common Use Case
viewDidLoad: One-time setup, called when app has already loaded the XIB but has not started to display
viewWillAppear: Called each time the view will begin to appear on screen. Setup data on screen such as labels.
viewDidAppear: Called when the view has completed being displayed to the user. Use for custom animations on hidden views.
viewWillDisappear: Called each time the view is about to begin disappearing. Use for more custom animations and for saving data to disk.
viewDidDisappear: View has disappeared and view controller may be removed from memory.
didReceiveMemoryWarning iOS will begin trying to reclaim memory. Release memory that can be recreated easily.


UIViewController is used as the base class for other common view controllers including UITableViewController and UICollectionViewController. These two additional classes will include other protocols that will need to be defined within the implementation.


The UITableViewController class creates a controller object that manages a table view.


The UICollectionViewController class represents a view controller whose content consists of a collection view


Apple UIKit Reference

View Controller Programming Guide