The following is a flowchart depicting a UIViewController
lifecycle:
The UIViewController
class is the base class responsible for managing the communication between model and view classes in an iOS. A View's lifecycle is defined by several methods that can be overridden in any class that inherits from UIViewController
. While you are loading a view into the display, these events will fire in the order they are listed here:
ViewDidLoad()
: This is arguably the most important event in any UIView's lifecycle. This method is called when the view and its entire display hierarchy have been loaded into memory, whether the view was created programmatically or loaded from a XIB file. This method is a good place to wire up event handlers and create any additional views that were not created programmatically or in the XIB file. Also, this is where you should do any configuration work that could not be done in the XIB file.