Using The Responder Chain

The delegate pattern is often used by a child view controller to communicate with its parent view controller, but it’s not the only way. A lesser used, but occasionally useful, alternate approach is the responder chain.

Read On →

Swift 5 Frozen enums

Are you upgrading an Xcode project to Swift 5? It’s a mostly pain-free experience, but you might hit a warning about switching on enums with additional unknown values.

Read On →

State Restoration With Swift Structs

How do you implement state preservation and restoration when your view controller model is a Swift struct that does not support NSCoding? My notes on how to wrap the struct in a dictionary with some help from Sourcery.

Read On →

Text Label vs Text Field vs Text View

If you’re new to iOS development the differences between a text label, a text field or a text view can be confusing. Here’s a quick guide for when you’re not sure which to use.

Read On →

Self-sizing Child Views

If you are struggling with massive view controllers you are likely to come across the suggestion to use container view controllers. A parent view controller splits a user interface into several, simpler, child view controllers. You add the root views of each child view controller to the parent which sets the size and position of the child views (manually or with Auto Layout).

What I find less well documented is how to implement a self-sizing child view. In this post, I look at how the UIContentContainer protocol allows the child view controller to tell the parent how big it wants to be (and an alternate, possibly simpler, approach).

Read On →
Archives Categories