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 ✌️
Greetings! I’ve been following your website for some time now and finally got the bravery to go ahead and give you a shoutout from Kingwood Texas! Just wanted to sау keep up the excellent work!
This is very cool. However, I’m getting a crash when I add in a UITabViewController and make my UISplitViewController one of the tabs… The message is not very helpful: “Terminating app due to uncaught exception ‘NSRangeException’, reason: ‘*** -[__NSArray0 objectAtIndex:]: index 18446744073709551615 beyond bounds for empty NSArray'”
Did you have this issue?
No, I don’t have any problems. But that sounds like you trying to access a value inside an array before you put something in it. Maybe it’s caused by the UITableViewController? Where and how do you initialize the items for the tableview to display?