What is VIewController?
View controllers play a crucial role for designing most iPhone applications.Let's have a look into my previous post -
Some important points About ViewController .Today, I am going to explain only the UIViewController Life Cycle.
The UIViewController class is the base class that establishes communication between model and View in iOS MVC design
pattern.The life cycle of a View is defined by some methods that can be overridden in many classes that inherits from UIViewController.
While we are loading a view into the screen, some events will be fired as explained here.
What Are The Main Responsibilities Of A View Controller ?
List of design patterns adapted by Cocoa.
UIViewController's code will call the loadView method to create the view for theview controller. The code of UIKit will call the loadView method if and when it actually needs to present that controller's view hierarchy on screen.As per the apple's documentation, no need to call these methods directly.You can just ignore these method,if you are using storyboard. Its implementation in UIVIewController loads the interface from the interface file and connects all the IBoutlets and IBActions for you.
This is one of the the most important events in view Controller's life cycle .UIViewController calls this method when the view has been created and loaded into memory along with all outlets.This method is called automatically when the view is already created programmatically or loaded from XIB.
Explain The Difference Between loadView() And viewDidLoad() in iOS
This method is called just before the view added to the display hierarchy. This method to update the user interface with data that might have changed while the view controller was not on the screen.
This event can be called many times for the same instance of a view controller
This method is called when the view is added to the screen.Usually,starting animations in the user interface,a sound, or to start collecting data from the network can be implemented here.
How to create a Coin Fall Animation
How to animate a view or image along a curved path.
This method is called prior to removing the view from the display hierarchy. If you override this method, you must always call base.ViewWillDisappear(). It's a good idea to undo anything that you implemented in ViewWillAppear() or ViewDidAppear().
This method is called after the view is removed from the display hierarchy.
This method can also be called when the view has already disappeared from the display hierarchy, which would normally occur if you have left large objects in memory and the system needs to dispose them to make room for other processes. If you override this method, you must always