I have a RootViewController which consists of two UIViewControllers all created in code (without Storyboard/Nibs).
The first UIViewController has the following anchors:
weekView.translatesAutoresizingMaskIntoConstraints = false
weekView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
weekView.heightAnchor.constraint(equalToConstant: 100).isActive = true
weekView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
weekView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
The other UIViewController has the following anchors:
daysViewController.view.translatesAutoresizingMaskIntoConstraints = false
daysViewController.view.topAnchor.constraint(equalTo: weekView.bottomAnchor).isActive = true
daysViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
daysViewController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
daysViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
Which makes it pin to the bottom of the first UIViewController and takes up the rest of the screen height (-100 from the top UIViewController).
The second UIViewController is a custom UIPageViewController which consists of multiple child views of UIViewControllers.
The problem
For some reason when scrolling through the pages in the UIPageViewController each child ViewController has the incorrect frame height (e.g not the same height as the constraint are telling it to have). Instead the frame height is the same as the screen height.
The printed frame height in the three different states are as follows:
viewDidLoad PageViewController frame: (0.0, 0.0, 375.0, 667.0)
viewDidLoad ChildViewController frame: (0.0, 0.0, 375.0, 667.0)
viewWillAppear ChildViewController frame: (0.0, 0.0, 375.0, 667.0)
viewDidAppear ChildViewController frame: (0.0, 0.0, 375.0, 667.0)
I need the correct frame size of 567 in the viewDidLoad to layout the subviews correctly and not so late as in the viewDidAppear.
How can I solve this? Because right now I need to take into account that the views frame is the full height of screen instead of the 567 it should be when creating all the subviews.