Using multiple detail views in a UISplitView with Storyboards in Xcode 4.2?

Chris Fox picture Chris Fox · Jan 6, 2012 · Viewed 8.2k times · Source

I'm trying to create an iOS 5 application with a SplitView Controller that uses multiple detailviews. Here's the rub. I'm trying to do it using Storyboards. I've found a number of tutorials explaining how to do it in previous versions of Xcode, but none addressing Storyboards.

The one exception creates a tab bar controller in the master view, which is not something I want to use. I tried removing the tab bar and modifying the code but was unsuccessful.

I did figure out that I could attach a replace Segue to a static cell in the master view. It allows me to specify the type as a detail split, which accomplishes most of what I'm trying to do. It loads the new detail controller.

However, the button that shows the master popover disappears during he transition. I believe I can probably prevent that from happening using this method:

  • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

Unfortunately, I'm not sure exactly what code to place there to prevent the button from disappearing. Do I need each detail controller as a delegate to the master somehow?

Has anyone gotten multiple detail views to work using storyboards and if so can you point me in the direction of a good tutorial? Thank you so much for the help!

Answer

Ray picture Ray · Jan 19, 2013

I faced a similar situation and checked the link to the raywenderlich.com. However I found managing the splitview delegate kind of too complicated, and it makes reuse between iPhone and iPad difficult. My solution is to create a DetailedContainerViewController as the right side view controller. And add the view controllers to be displayed on the right side as the child view controllers of the container controller. In this way only the DetailedContainerViewController needs to implement the SplitView delegate. So there is no need to worry about the delegate.

Take a look at the sample code I wrote on github:

https://github.com/raoying/SplitView-Sample