Storyboard:

![Storyboard](https://i.stack.imgur.com/kbW9n.png)

Constraints:

![enter image description here](https://i.stack.imgur.com/8CHQg.png)

Result:

![enter image description here](https://i.stack.imgur.com/PAfs5.png)

I'm trying to understand autolayout and how I can use it inside a container.

I got a default ViewController that was made for me when I opened the Storyboard. I put a View Container inside there. And then I added a loose (not connected to anything) ViewController. I want the content inside the new ViewController to be put in the container.

So the added ViewController which will be put inside the Container consists of three labels where I am using autolayout.

Clicking on the black bar for the Container View Controller in the Storyboard I go to Identity Inspector and set the Custom Class to "ContainerViewController". Then I set the Storyboard ID to "ChildController" for the loose View Controller.

Then I override `viewDidLoad` in `ContainerViewController.m`:

```
- (void)viewDidLoad
{
    [super viewDidLoad];

    UIViewController *child = [self.storyboard instantiateViewControllerWithIdentifier:@"ChildController"];
    [self addChildViewController:child];
    [self.view addSubview:child.view];

}

```

Why won't the constraints for the autolayout work when put in a container? I hoped they would, so I could take this further to a UIPageViewController.

**EDIT:**

So it seems to be the frame size. I need to do something like this before adding it as sub view:

```
child.view.frame = CGRectMake(0, 0, 265, 370);

```

Now I created an outlet for the Container in `ViewController.h`. 

```
@property (weak, nonatomic) IBOutlet UIView *container;

```

But.. From ContainerViewController, how can I ask presenting view controller (ViewController) of this property when it's not set yet?

```
ViewController *parent = (ViewController*)self.presentingViewController;
UIView *container = parent.container;

NSLog(@"ParentView Container Width: %f, Height: %f", container.frame.size.width, container.frame.size.height);

```

It just gave me zero width and height, because the view hasn't loaded yet. Later on when it loads, I get the actual values..

```
NSLog(@"View Controller Container. Width: %f, Height: %f", self.container.frame.size.width, self.container.frame.size.height);

```

**The question:** How can I access properties of presentingViewController when they are ready/loaded?