Demystifying Views in iOS
Learn to organize your app ideas and designs in ways that work well with the latest versions of UIKit and Interface Builder. Eradicate View and View Controller confusion! By Jessy Catterwaul & Catie Catterwaul.
Part 1: Nib Files
Get a little background on what these "views" are, that we'll be demystifying. Then find out the app you'll be building.
Create a nib file: the predecessor to the storyboard, and still a great option for designing views in Interface Builder.
Use a Bundle to load a nib, and then integrate the nib into your storyboard – both at runtime, and in Interface Builder.
A nib file's owner allows it to connect to its external environment using the convenience of Interface Builder outlets and actions.
You've got a view controller and a file's owner for your nib. If you can hook them together, you'll have successfully integrated interactivity with your nib.
You know how to connect outlets from a nib, to its File's Owner, and from the File's Owner to a view controller. But you can connect inter-nib objects too!
Sometimes you'll want to load objects from a nib multiple times. UINib is a better match for those cases than instantiating repeatedly from a Bundle.
You've used the nib you designed once in a storyboard. Now use it again four times over, all within an entirely new nib!
You've now learned all about a powerful tool: nib files! Let's review their similarities to storyboards and when nibs are more appropriate.
Part 2: Temporary Subviews
Part 1 is all about views, and Part 2, view controllers. This part will bridge the gap, with a focus on views that don't stay on-screen all the time.
Explore, in Swift, how you can take control over subviews (including ones loaded from nibs!) without necessarily using a view controller.
Learn to integrate a parent view into a view controller. The view controller will have to do some coordination, but its subviews can take over from there.
Get some experience designing a view in the Scene Dock. It's a great place to put temporary views that are associated with only one view controller.
Combine the power of a custom UIView subclass and a Scene Dock object that uses that class. Storyboard scenes are flexible!
You're not limited to one temporary view in a scene. It's also possible to interact with Scene Dock views, and have them stick around until dismissed.
Although custom UIView subclasses for Scene Dock views are a helpful tool, they're not always necessary to get the job done. Go without, this time!
Views in nibs, views in the scene dock, view in parent views: when they're subviews of a view controller and temporary, you've got them down.
Part 3: Container View Controllers
Before you can convert one of your views to be a controller, get an idea of what a container view controller is, and its role in dependency injection.
It's time to power up your view to become a view controller! You'll learn to convert from a nib to a storyboard, and get started coding it as well.
There's a little bit more to worry about when adding a child view controller than there is for just a subview. Let's sort out the extra requirements.
Embed segues are an alternative to loading child view controllers in code, After this video, you'll be able to gauge which method is right for your needs.
It's time to see how much of what you've created for your first contained view controller can be reused for your latest one.
You'll be making the final view controller for the course, and using one of Apple's own container view controllers with it. Storyboard references make it easy!
Come get acquainted with the basics of View Models. You'll define one for a custom view lass, and then manage a collection of them with their view controller.
You've been coordinating between two parts of the screen with one container view controller. Now coordinate between two screens, with another.
Review the big ideas of what you've learned in the course. Start considering how all of your new view-organizing skills can benefit you in a team environment.