Adding a New UIViewController
As the name suggests, UIViewControllers are objects that control a view. The UIViewController object stores the UIView it manages inside the view attribute. However, we generally don’t use addSubview: to add this particular view to the screen; instead, various methods will often take the entire UIViewController object and adjust the view as necessary before adding it to a hierarchy.
Let’s get started with a small project to see how UIViewController works, and you’ll see what I mean. We’ll create an app showing different ways to explore colors, specifically, motion create ColorViewer.
First we make the ./app/controllers directory (mkdir ./app/controllers). This is where we’ll keep all of our controller classes. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access