0

I was reading the documentation:

You need to decide how many children can be displayed by your view controller at once, when those children are displayed, and where they appear in your view controller’s view hierarchy.

But in which method should I position the view controller children's view? Say I have two UIViewController in the container and I want one next to the other.. how do I do this?

Caleb
  • 124,013
  • 19
  • 183
  • 272
adit
  • 32,574
  • 72
  • 229
  • 373

3 Answers3

1

In one of my articles I demonstrated how to create a simple dashboard app using UIViewController Containment.

http://www.highoncoding.com/Articles/848_Creating_iPad_Dashboard_Using_UIViewController_Containment.aspx

azamsharp
  • 19,710
  • 36
  • 144
  • 222
  • You should include some actual text explaining what to do here on stack overflow. Part of what constitutes a 'good' answer here is that the salient portion of any linked content is present in the answer in case the linked content ever goes away. – griotspeak May 08 '14 at 21:49
0

Each of the child view controllers has a view property. You can set the frame of those views when you add them to your own view.

Caleb
  • 124,013
  • 19
  • 183
  • 272
0

It depends on the context of the situation that you may have. If you need to display all of the children when displaying the view for the first time, then add the view controllers and views in viewDidLoad ( if using a xib or nib) or in loadView ( if done programatically). If you need to show the child view controllers on demand, like after the touch of button, then you can add the child view controller and associated view in a separate method.

You will need to layout the views of the child view controllers as you would layout any other subviews. Remember view controller containment is just another ways of allowing you to modularize your code.

Check out this link which helps explain how to add the child view controllers: Animate change of view controllers without using navigation controller stack, subviews or modal controllers?

Here is a simple sample project that shows how to add child view controllers:https://github.com/toolmanGitHub/stackedViewControllers

Good Luck!

Community
  • 1
  • 1
timthetoolman
  • 4,613
  • 1
  • 22
  • 22