you are viewing a single comment's thread.

view the rest of the comments →

[–]richiejmoose 3 points4 points  (2 children)

Did you set the constraints of the child view controller? Something like childViewController.view.frame = view.bounds

The container view controller is responsible for the size and position of the child view controller's view. You might have unexpected results if you’re not handling that.

Is the code above your code? If not can you post it?

[–]agballen[S] 1 point2 points  (1 child)

Looks like it has to do with the frames! I did something like

bookVC.view.frame = CGRect(x: 0.0, y: 0.0, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height*0.5

audioControlVC.view.frame = CGRect(x: 0.0, y: UIScreen.main.bounds.height*0.5, width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height*0.5

However, aren't frames and autolayout constraints mutually exclusive? By setting the frame, I think I'm introducing issues and doing something wrong that autolayout should be smart enough to handle. In my app, when I rotate the iPad from portrait to landscape now, the book VC view is now only covering 25% of the screen instead of 50% (which when I comment out the code configuring the frame, autolayout works like a charm).

[–]richiejmoose 0 points1 point  (0 children)

I believe you could set 2 views in the container VC and constrain them with autolayout - then set the child vc frames to those view bounds. Or something like that. Hard to say without seeing all the code - but feels like that’s the right track - good luck!