I have a parent view controller with 2 views.On Top, I have View, that contains Page View Controller and on Bottom I have other view that shows different content.
Everything works well, except getting white space below first view ( Page View Controller) and above second view.
I have added following code for constraints,
let views:[String: Any] = ["pageView": pageViewController.view!]
articleContentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "H:|-0-[pageView]-0-|",
options: NSLayoutConstraint.FormatOptions(rawValue: 0),
metrics: nil, views: views))
articleContentView.addConstraints(NSLayoutConstraint.constraints(withVisualFormat: "V:|-0-[pageView]-0-|",
options: NSLayoutConstraint.FormatOptions(rawValue: 0),
metrics: nil, views: views))
If I remove this code , My Page View Controller exceeds its view and occupy full screen. Any suggestions much appriaciated.
The "blank space" is almost certainly the Page View Controller's built-in UIPageControl
.
Here's a quick example, with two views... the top view has a UIPageViewController
added as a child view controller, and the Top of the bottom view is constrained to the Bottom of the top view:
Notice the "empty space" ...
Using Xcode's Debug View Hierarchy, it's pretty obvious why:
So, if I set a background color on the Top view, I see this:
It appears to be empty space, because the default Page Control uses tinted white dots - so we don't see anything on a white background.
Edit
The PageControl is automatically shown if your controller's DataSource
implements both of these optional methods:
optional func presentationCount(for pageViewController: UIPageViewController) -> Int
optional func presentationIndex(for pageViewController: UIPageViewController) -> Int
Removing one or both will automatically remove the page control.