Search code examples
iosobjective-cuisplitviewcontroller

Dynamically Change Detail View Controller


I have a Split View controller set up in Storyboard, and I need to be able to change the Detail View Controller dynamically. By default, the Detail View Controller has a "relationship" segue to a Navigation Controller, which leads to the original Detail View Controller. How can I dynamically change this relationship to another controller?


Solution

  • You can do this a couple different ways. If you want to do it all in storyboard, you can create a segue from your master view controller buttons or cells to your detail view Controller and choose the "replace" segue option. You can also do this in code where your master view controller stores a reference to the detail view controller (UINavigationController) and replace out the root view controller.