Search code examples
iosipaduisplitviewcontroller

Split view MasterViewController with multiple table views


I have a split view working great. However, I'd like to be able to drill down on my Master-Detail view's UITableView. For example, I have a list of ages: 0, 1, 2, 3, 4, 5. When the user presses 3 I would like a new UITableView to be presented with all the kids names that are 3.

Ideally I'd like use Storyboards to accomplish this (link an add button to take me to the next UITableView). When I try and add a view it shows up as a full screen view. How can I make this view show up in the Master section of the split view?


Solution

  • When using Storyboards, if you want to have multiple UITableViews so it will allow the user to drill down categories, you must use the Push Segue (set it to Master). Make sure you are not pushing a UINavigationController, but just the view you want listed. Then, to get back just use [self.navigationcontroller popViewControllerAnimated:YES];.

    EDIT: (more info as asked for) So in XCode/IB when you are on your main view and right click and drag it to another view, you will be presented with different choices. You want to select Push instead of Modal. This will allow it to push a new view onto the stack. You can also set it's destination to Master and it will size the IB view correctly.

    Also, you don't always have to use a button to connect a view. You can also drag from the view controller itself to another view controller instead of a button to view controller. Then in your button code you can call [self performSegueWithIdentifier:@"someNameHere" sender:self]; to call the transition. This lets you do checks and validation before you move on to the next screen.

    Just remember to click on your segue and name it (under identifier in the properties view). Then add the function prepareForSegue:sender: in order to transfer any variables or anything before it transfers (I rarely have to use this).