What is UIViewController ?
The word UIViewController itself tells the meaning. A Controller which controls or manages a UI of View. This is the place where you add views to create a beautiful user experience for your iOS App.
What is UIView?
UIView is a place which tells your iPhone's full screen to give some part of the screen so that it can define a view own in its own way.
Example: A part of the screen with height 60.
UIViewController's view Life Cycle:
1) viewDidLoad - It is automatically called when the view controller is loaded completely in the memory. An initialization of Objects is done here.
So for example, if my view is a form with 3 labels, I would add the labels here; the view will never exist without those forms.
viewDidLoad is used to initialize setup of your interface. It is called only once in the entire lifecycle. or when you want to create database access or when you want to prepopulate the data etc.
2) viewWillAppear - This is called every time the view is about to appear, whether or not the view is already in memory. Put your dynamic code here, such as model logic.
Example:1) Update navigation bar style
2) Update status bar style
3) Update screen data
4) Orientation handling
3) viewDidAppear - Put expensive operations here that you only want to do if you're sure the view is onscreen, such as network calls.It is called when the view controller's view was added to the view hierarchy.
Example :-1) Start UI animation
2) Display loader view
4) viewWillDisappear - It is called when the view controller's view is about to be removed from the view hierarchy.
Example:1) Hide keyboard
2) Revert changes that were made in the viewWillAppear() method.
5) viewDidDisappear - It is called when the view controller's view was removed from the view hierarchy.
Example :-1) Remove cache data.
Largest collection of up-to-date tutorials to learn programming languages. We are focused on easy learning. Massive collection of interview questions one may need for preparation.