UIButton on all pages of UIPageViewController

I am working on an iPhone app and am creating UIPageViewController

(lets call it a container ) that contains multiple pages UIViewController

(lets call them subpages ). The subpage transition style is scrolling.

Now what I like to do is create a button in the upper right corner of the container and NOT in subpages . The idea is that the button will remain on the screen when subpages are scrolled from one page to another. If I create a button in one of the subpages , then each subpage will have its own button and the button will scroll with the subpages . I want to keep the button without moving in the containerand scroll through subpages .

I tried to add a button using storyboard to container but it is now allowed. I cannot drop it, and I suspect the reason is that container > is of type UIPageViewController

.

How can I do this with a storyboard?

Thank.

+3


source to share


3 answers


  • In your storyboard, create a default Scene Viewcontroller.
  • Add fixed buttons and a container view to this scene.
  • Adding a container view will automatically add an inline view controller. Select this and delete it.
  • Drag a Page View Controller to the storyboard.
  • Select the container view and drag it from the viewDidLoad element in your triggered segues list onto the page view controller. Select "Paste" as the segue type.


+11


source


In code add button to uipageviewcontroller



0


source


Drag the button to the controller (UIPageViewController) (make sure it's a good controller). And add a constraint to block it in the top corner.

-1


source







All Articles