Search code examples
iosuipageviewcontroller

UIPageViewController has strange size


I am using a UIPageViewController in my app. It works quite well, but when I turn pages, the next page seems to get initialized in a frame that is bigger than the screen: While turning the page, only a part of the view of the next viewController fits on the screen.

I am initializing the UIPageViewController in viewDidLoad and started to log the frames of the PageVC, its subviews and the parentVC. Every frame seems to be okay, only the UIPageViewController's frame, which I log in viewControllerAfterViewController has a width that is nearly the double of the screen's actual size.


Solution

  • I finally solved this issue by setting the right frame to the UIPageViewController's view when initializing the PageVC:

    pageViewController.view.frame = self.view.frame;
    

    Where pageViewController is the UIPageViewController I initialize, and self is the parent VC of the pageVC.

    Hope this helps anyone with similar problems.