Search code examples
iosxcodecocoa-touchstoryboarduisplitviewcontroller

Master view doesn't show when I add Split View Controller to a Storyboard


I'm very new to storyboarding (also pretty new to iOS programming in general). I'm trying to add a Master/Detail view to my storyboard for an iPad only app. Here's what I've got so far:

  1. A main Tab Bar Controller that drives the navigation for my app. This is working.
  2. I've added a Split View Controller object to the MainStoryBoard from the libraries.
  3. Ctrl+drag from my Tab Bar Controller to the Split View Controller, select Relationship Seque->view controllers. This successfully adds the Split View Controller as a new tab item (which is what I want).

But now when I run my app and click on the new tab item, is just opens the detail view without the master view showing anywhere. I obviously haven't added any data yet, I just want to make sure everything is working first. Will the master not show if it's emtpy? That's not how other table controllers have worked for me; they've all shown empty tables. Which is what I'm looking for here so I can proceed with wiring the detail up on the left.

The Split View Controller looks a little foreign to me, as the first controller says 'Detail View Controller' with segues to a Navigation Controller then Table View Controller for the master, then a simple View Controller for the Detail. All that makes sense to me except that entry point calling itself a Detail View Controller. Which is what shows when I run it with no master popover/left pane table.

Update: When I start with a Master-Detail Application template, the Split View Controller object has both the Master View Controller and the Detail View Controller shown in that main screen. So something is different when I just drag it from the library. How do I accomplish the same thing in on existing storyboard without using the template? I've wired quite a bit of the rest of the navigation up around the Tab Controller that I would prefer to not redo.

Thanks.


Solution

  • You cannot use a Split View Controller as one item of a Tab Bar Controller.

    See for example http://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/SplitViewControllers.html

    A split view controller must always be the root of any interface you create. In other words, you must always install the view from a UISplitViewController object as the root view of your application’s window. The panes of your split view interface may then contain navigation controllers, tab bar controllers, or any other type of view controller you need to implement your interface. Split view controllers cannot be presented modally.

    Update: This seems to be wrong as of Xcode 6.1 and iOS 7/8. See @headache's answer.