Question

I have my app mapped out using storyboards where there is an entry screen that segues to a tabbarcontroller which contains 3 tabs. Each tab contains a splitviewcontroller and I have written classes for each master and detail view controller. The bit I'm not sure on is how to give each masterviewcontroller (that controls the table on the left hand side) a reference to the detailviewcontroller.

I can see in the attributes inspector there is an identifier field, should i put something in here for the detailviewcontroller (e.g. 'detailviewcontroller1) and then somehow get that object by it's instance name in code?

Was it helpful?

Solution

Both your master and detail view controllers will have a property, splitViewController, that holds a pointer to the split view controller.

The split view controller has a property, viewControllers, which holds an array of the view controllers contained in the split view. This array will always contain 2, and only 2, view controllers - at index 0 is the master controller, and at index 1 is the detail controller.

OTHER TIPS

So your SplitViewController should be connected to 2 segues that connect two separate UINavigationControllers (one for Master and one for Detail). These two nav controllers will connect to your two VC's (Master and Detail).

You will then create a property for that detail VC inside the master VC and pass whatever data you need to when the user selects a row from the TV.

If you need to see how this is supposed to be layed out and wired up, just create a new iPad application using the Master-Detail template.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top