I’m new to Xcode and starting a universal app. In the iPad version I want to re-use the main section for different search forms.
I want the user to see a completely different form in the section to the right (see image) for each button on the left menu.
I’m working programmatically.

What’s the best way to change the content in this situation? (keeping in mind performance and coding complexity)
EDIT: This is a standard tabbed application, not a split view. Could I have a new view controller and .xib for each form and then change which one is displayed by embedding them in a UIView or UIWindow on this screen?
You’ve hit upon the right answer in your edit. From what I understand the buttons on the side are analagous to another tab bar controller, but nested within your main tab bar controller?
You might as well follow the same pattern, since it is a familiar one. Your search view controller should act as a container view controller, which would have an array of view controllers representing each form option.
As you switch between the options, add/remove the appropriate view controller views from your view hierarchy (using
addSubview) and view controller hierarchy (using the code in “Adding and removing a child” in the link). The view controller hierarchy is important to ensure that viewDidAppear and so forth is called on your child controllers.As an illustration, I’ve created a simple demo project where the main view controller has a set of buttons, each linked to the same action, and an array of contained view controllers. The contained view controllers will be held inside a subview, called
containerin this example. This would be the size of the right hand area in your screenshot above.The child controllers are set up as follows in
viewDidLoadof the container view controller:Here I’ve used four instances of the same view controller class – all it has is a label which indicates which form you are selecting. Really you’d have different classes for each one. I’ve also “selected” the initial view controller by sending the action method for the first button. The action method does this:
Which selects the appropriate VC from the view controller array. The setter method does this:
Which sets up the view controller hierarchy, adds in the view and uses constraints to make it fill the container.
In this example I’ve hardcoded in four buttons and four child view controllers as I was demonstrating the addition and switching of child view controllers. In reality you’d make it more like a tab bar controller where you assign an array of view controllers and the container would make its own array of buttons.