Updated 1 October 2020
iOS View Controller Life manages a set of views and makes your app’s user interface. It coordinates with model objects and other controller objects. Basically, it plays a combined role for both view objects and controller objects. Each view controller shows it’s own views to display the app content. The views are automatically loaded when the view property of the view controller is accessed in the app.
A View Controller provides multiple methods for manage the views.
loadView
This method use when view Controller create from code .Its good not to do anything on this method .If view Controller made from .xib or storyboard.
What Do in View Load : loadView( ) is a method managed by the viewController. The viewController calls it when its current view is nil. loadView( ) basically takes a view (that you create) and sets it to the viewController’s view (superview).
View Did Load Method
This Method is loaded once in view controller life cycle .Its Called When all the view are loaded .You Can do Some common task in this method :
1.Network call which need Once.
2.User Interface
3.Others Task Those are Need to do Once
View Did Appear Method
The viewDidAppear
the method is called after the root view is displayed. This method is commonly overridden to initiate processor-intensive work that otherwise could cause sluggishness in presenting the view.
View will Appear Method
This method is called every time when the view appears.
View Did Appear Method
This method is called after the view present on the screen
View Will Disappear Method
This method called before the view are remove from the view hierarchy
View did disappear Method
This method is called after the VC’s view has been removed from the view hierarchy. Use this method to stop listening for notifications or device sensors.
View will layout Subviews Method
It don’t do Nothing by default. When a view’s bounds change, the view adjusts the position of its subviews. View controller can override this method to make changes before the view lays out its subviews.
View Did Layout Subviews Method
This method is called after the viewController has been adjust to its subview following a change on its bound.Add code here if you want to make change to subviews after they have been set.
Thanks for reading this blog, this will help you to learn view life cycle and You can get other blogs from here.
So pls follow the above step and And if you have any issue or suggestion you can leave your message in the comment section I will try to solve this.
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.