UPDATE 2
I\'ve been running and testing my app in the iOS Simulator using a 4-inch device. If I run using a 3.5-inch device the label doesn\'t jump.
As @djibouti33 already posted:
a pageViewController couldn't properly lay out it's child view controller initially if it contained a scroll view. by the time we're in layoutSubviews, pageViewController seems to have gotten it's bearings and everything is laid out just fine
By waiting for layoutSubViews to load before setting any viewControllers to the UIPageViewController was the only thing that worked for me.
override func viewDidLoad() {
super.viewDidLoad()
self.pageViewController = self.storyboard?.instantiateViewController(withIdentifier: "yourPageViewController") as? UIPageViewController
self.pageViewController?.dataSource = self
pageViewController?.automaticallyAdjustsScrollViewInsets = false
self.pageViewController?.view.frame = CGRect(x: 0, y: 0, width: view.frame.size.width, height: view.frame.height)
self.addChildViewController(self.pageViewController!)
self.view.addSubview((self.pageViewController?.view)!)
self.pageViewController?.didMove(toParentViewController: self)
}
override func viewDidLayoutSubviews() {
let startVC = self.viewControllerAtIndex(index: 0) as infoDataViewController
let viewControllers = NSArray(object: startVC)
self.pageViewController?.setViewControllers(viewControllers as? [UIViewController], direction: .forward, animated: true, completion: nil)
}