I know what a UIView
is but not a UIViewController
. I just want to know what I could use it for, and what it is compared to a UIView
Both are used for different purpose. A UIViewController class manages a ViewContoller which is responsible for actions that happen within that View controller. This class is aware of actions that happen on view controller, like ViewDidLoad, ViewWillApper, ViewDidAppear, ViewWillDisapper, ViewDidDisapper.
The LifecycleThe view controller lifecycle can be divided into two big phases: the view loading and the view lifecycle. The view controller creates its view the first time the view is accessed, loading it with all the data it requires. This process is the view loading.
A view controller manages a single root view, which may itself contain any number of subviews. User interactions with that view hierarchy are handled by your view controller, which coordinates with other objects of your app as needed. Every app has at least one view controller whose content fills the main window.
An abstract interface for responding to and handling events.
Basically you need to know, what is model-view-controller architecture in the software engineering field, the UIView
corresponds to view of this architecture and UIViewController
is at controller side of this architecture.
Now UIViewController
can be thought as an agent that controls (and has the implementations of methods) the events and design of the UIView
that is shown on the screen. Anything you want to change on the view can be written inside a method in its controller class, that inherits itself from UIViewController
class. That is only the brief description of this big concept. For details you should look for the above link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With