UISplitViewController on iPad with Storyboards?

user568866 picture user568866 · Feb 14, 2012 · Viewed 8.6k times · Source

enter image description here

In Xcode, how can I create a simple iPad application that uses Storyboards such that the DetailView controller is swapped out for each entry? Most examples that I've seen use the iPhone or they simply change the values in the same detail view controller.

I want to create the segues in Interface Builder from a static TableView Controller (with say 3 rows) where each row will load a different game detail view controller, which I would drag out and design in IB. Currently, when I connect a view controller with a segue, it replaces the navigation part of the UISplitViewController. In other words, it's like I'm traversing a tree, and I need to tell IB that I'm at a root node and I should be changing the Detail View.

Answer

user568866 picture user568866 · Apr 9, 2012

A good starting point for segues are Lectures 6 and 7 of Stanford's CS193p Fall 2011 class.

http://itunes.apple.com/us/itunes-u/ipad-iphone-application-development/id473757255

The instructor, Paul Hegarty, covers everything. However, he runs out of time before the end of class to answer this question. He does include the source with the final solution in the file: Psychologist with Dr Pill.zip.

http://www.stanford.edu/class/cs193p/cgi-bin/drupal/downloads-2011-fall

Basically, all that needs to be done for this question is to Ctrl-drag from each UITableCell to the respective game detail view controllers then select the Replace segue. There is one more step because the view controller will shrink because by default Xcode thinks that you want to replace the master controller. For each of the segues, select the connection line and in the Attributes inspector then change the Destination from "Master Split" to "Detail Split". At this point, you can test with the popover, without writing any code.

Master Split Destination

Detail Split Destination

Solution