UIPageViewController with Constant Elements (that don't move on swipe)

ios, uipageviewcontroller, uiview

Solution

Instead of adding the `UIButton` to the `UIPageViewController` which as you stated would move along with page swipes, do this:

- Create a UIView

- add the UIPVC to the newly created view as a subview

- also add the UIButton to that newly created view as a subview too.

Now you have two subviews in this newly created `UIView` and they would be separate views that you can interact with without it affecting the other

What you were doing before was adding the `UIButton` to the `UIPVC` which is not what you want as explained in the opening paragraph

Problem

I'm creating a full screen image viewer for my app (i.e. click on a thumbnail and a full-screen viewer opens up that allows for zooming (UIScrollView) and swiping to the next image). I'm currently presenting the UIPageViewController as a modal view. I can't seem to figure out how I can place a "Close" button on the screen so I can dismiss this modal view. I tried to include the "Close" button on the UIPageViewController's content pages but these items move with each swipe (as they are supposed to). So, how can i create a button that sits above the UIPageViewController and allows me to close this view? Seems like a simple issue but can't seem to find a good solution.

Original source