Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIButton across all pages of UIPageViewController

I am working on an iPhone app, and created a UIPageViewController (lets call it the container), which contains a number of UIViewController pages (lets call them the subpages). The subpages transition style is scroll.

Now, what I like to do is create a button on the top right corner of the container and NOT in the subpages. The idea is, the button will stay on screen when the subpages scroll from one page to the other. If I create the 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 container, while the subpages scroll.

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

How can I do that using the storyboard?

Thanks.

like image 473
Greeso Avatar asked Nov 23 '14 03:11

Greeso


1 Answers

  1. In your storyboard, create a standard Viewcontroller scene.
  2. To this scene add your fixed buttons and a container view.
  3. Adding the container view will automatically add an embedded view controller. Select this and delete it.
  4. Drag a Page view controller into the storyboard.
  5. Select the container view and drag from the "viewDidLoad" item in its "triggered segues" list to the page view controller. Select "Embed" as the segue type.
like image 56
Paulw11 Avatar answered Oct 21 '22 02:10

Paulw11