Thanks to the WWDC 2015 video, Implementing UI Designs in Interface Builder, I learned, among other things, not only that Xcode supports tabs with different view configurations and that you can have multiple assistant editors open in each tab, but also that there’s a pretty nifty tip for quickly placing a file in any of those tabs, and primary or assistant editors!
Just option-shift-click on the file, and up pops this HUD…
Then select which view you want to place it in, or first add a new tab or assistant editor, and then hit return. Simple!
I recently developed a passcode view with core functionality that allows a user to tap in a 6-digit passcode. I then added functionality to support two different modes of operation: new passcode entry and existing passcode entry. I had a single view controller that managed these two modes of operation. The mode was ultimately determined by two different calling view controllers that segued to it.
And it was just too complicated for my tastes.
So I set out this weekend to break it up. I ended up with three controllers: one for the basic passcode-entry functionality, a second for the new-passcode additions, and a third for the existing-passcode additions.
But how to handle this in Interface Builder? Thanks to Xcode 7 and the help of Mike Woelmer, container views was the answer.
As illustrated above, I simply added two additional view controllers to the storyboard, one for each mode of operation, set their Custom Class to one of the new UIViewController subclasses I’d just created, and filled their view with a Container View. Then I embedded the single passcode view controller into each by control-dragging from the container to the passcode controller.