The UIViewController lifecycle

viewDidLoad, viewWillAppear or viewDidLayoutSubviews?

Steven Curtis
5 min readMay 17, 2020
Photo by Joseph Pearson on Unsplash

Difficulty: Beginner | Easy | Normal | Challenging

Prerequisites:

There is always much talk and thought about “what goes where” when thinking about and designing new iOS apps. You might well be familiar with the Application Life Cycle, but were you aware of the view controller’s similar journey?

Even if you are, I hope this article will help you out in understanding this essential part of UIKit.

Setting up a View Controller

A new instance of a UIViewController can be set up by simply creating a new Single View Project from Xcode. This quickly sets up the following:

Which reveals that there are important thing to note. The ViewController is actually a subclass of UIViewController, which means that we have access to various methods which we can override to use.

The first of these is viewDidLoad() which most developers are familiar with, and I will go into detail about later in this article.

We are already given the like super.viewDidLoad() which is great, since we should be calling super for our…

--

--