Search code examples
iosmaster-detailuistoryboardseguerootview

Multiple Master-Details with root view - iOS


I have a master-detail application. The master scene is a tableview and the detail is a simple view controller with some text.

I'd like however to have more than one master-detail (one for every topic), and a homepage, with images / buttons. When I click on one of them, I want to get transferred to the corresponding master-detail.

I added a view controller to the story board (call it A), changed the root view to A, added a button in A and added a push segue from that button to the master scene (ctrl+drag). But this does not seem to work when I run it.

Any ideas? Thank you

I figured it out - I was using

UINavigationController * navController = (UINavigationController *) self.window.rootViewController;

MasterViewController * masterController = [navController.viewControllers objectAtIndex:0];

and the object at index 0 was no longer the master view controller.


Solution

  • To have multiple "master-detail" you will need to push controllers from both sides using UINavigationControllers. First make sure that your A controller is inside a navigation controller, and if it is but still not working, then check the storyboard because there's probably some error or something not linked