UIPageViewController: how to add a non-paging toolbar or other "overlay" elements?
cocoa-touch, ios, uikit, uipageviewcontroller
Solution
We should create `UIPageViewController` programmatically and add its view to another `UIViewController`'s view as a subview. And the elements that we want them to be 'overlay' should be subviews of the host `UIViewController`.
For example, in `- viewDidLoad`:
UIPageViewController *pvc = // init this on your own way
pvc.dataSource = // your data source
// Set page view controller's view's frame to match host view's frame
pvc.view.frame = self.view.bounds;
// And here comes the magic
[self.view insertSubView:pvc.view belowSubview:<any subview>];
Briefly we only use `UIPageViewController`'s view but not itself.
Hope this helps.
Problem
I have implemented a PDF viewer. Currently it is a `UIViewController` that contains a `UIPageViewController`. My toolbar, some overlay elements (like quick access to certain pages of the PDF) are added to the standard `UIViewController's` view. However I wonder if that is required? Would it be somehow possible to inherit from `UIPageViewController` and have the paging effect for sub controllers and still have "floating" elements on top that won't be paged? or is the containment the way to go?