Implementing UISplitViewController: Better than I’d feared, worse than I’d hoped.

I’ve been working with iOS development off and on—mostly off—for the past few years now. In that time, I can remember the Xcode experience before they merged Interface Builder with the rest of the IDE: It was somewhat reminiscent of what Visual Basic (pre-.NET) looked like going from Visual Basic 4.0 to Visual Basic 5.0.

It worked, but it wasn’t the most eloquent situation.

But I digress: The main point of this post is to discuss my disdain for the idea of creating universal apps: Those apps that are optimized for both the iPhone/iPod Touch and iPad devices.

I’ve only somewhat recently gotten used working with Storyboards and Autolayout on iPhones, so I was more than a little apprehensive about expanding that repertoire into the iPad domain.

And then I found this post over at NSHipster discussing UISplitViewControllers and their robustness. I tried it out by applying it to my current app in the works, Muster PO, and I was mostly floored by how simple it was to get everything working at a basic level.

Still, there were going to be some quirks with it, especially since I was going about the UI in a way that seems to not be—at least, from the UISplitViewController documentation—supported out of the box without a little legwork on your part.

Long story short, my master view controller is a UITabBarController, and my detail view controller is a UINavigationController. Getting the subviews from the master view controller to play correctly with either the master or the detail views ended up being a bit tricky, but through StackOverflow, I was able to find this eloquent solution:

- (BOOL)splitViewController:(UISplitViewController *)splitViewController showDetailViewController:(UIViewController *)detailVC sender:(id)sender {
if (splitViewController.collapsed) {
UITabBarController *masterVC = (UITabBarController *)splitViewController.viewControllers.firstObject;
UINavigationController *navigationController = masterVC.selectedViewController;
     if ([detailVC isKindOfClass:[UINavigationController class]]) {
UINavigationController *detailView = (UINavigationController *)detailVC;
detailVC = detailView.topViewController;
     [navigationController showViewController:detailVC sender:self];
     return YES;
return NO;

It works well enough for what I need it to do, though there are still some glitches.

I’ll keep working at it until most of them are gone, and then keep working on from that point until they’re all gone.

…Hey, one can hope, right?

Show your support

Clapping shows how much you appreciated Terrance Shaw’s story.