I like Apples container view controllers. They are familiar for the users since they are used everywhere in the system and they give you a lot of possibilities to create convenient UIs without writing a lot of code. They are subclassable and they have useful protocols which you can implement so often there is not even the need to subclass.

Though they sometimes have their culprits. For example, when you try to embed a UISplitViewController from another Storyboard inside a UITabBarController.

Personayll I like to keep my Storyboards clean and I don’t like to overcrowd them. I think of a Storyboard as a part of my UI which is a closed user story. Like a combined login/sign up screen or a master-detail flow.

Especially when it comes to UITabBarControllers on the applications top level, I often create a separate Storyboard for each tab. And sometimes I end up putting a UISplitViewController in one of those tabs.

And here comes the problem. If the UISplitViewController is the initial view controller of your Storyboard, you won’t be able to set it’s tab bar item icon and title via the Storyboard. It was kind of frustrating and in the beginning, I would subclass UITabBarController and setup all titles and icon there.

Fortunately I just found a better way. Simply place a UITabBarController inside the Storyboard where the UISplitViewController is the initial view controller and make the UISplitViewController one of the UITabBarControllers view controllers by dragging the appropriate Segue.

Now you can set the tab bar icon and title directly on the UISplitViewController and you don’t even need to make the UITabBarController the initial view controller. All you have to do is give it an identifier to get rid of the warning that it is not reachable and you are good to go.

For me this is definitely good enough for now and I hope it will save you some headache as well some day. Cheers ✌️

Pin It on Pinterest

Share This