Search code examples
ios6embeduistoryboardseguecontainer-view

Using a UIPageViewController with an embed segue


I'm working on a client project that uses UIPageViewControllers.

The app has a hierarchy of "collection" view controllers that the user navigates through to get to (in this case) a page view controller that contains pages of content.

My design is to have the hierarchy of "collection" view controllers be custom subclasses of UIViewController that know how to manage collections of child view controllers with the client's desired UI.

My view controller that displays a page view controller is a subclass of my parent collection view controller, and that parent view controller class might manage page view controllers, cover-flow style view controllers, table view controllers, or a variety of others.

Ok, so I can't make my view controller that manages a page view controller a subclass of both my parent view controller and of UIPageViewController.

This is an iOS 6 project, so I decided to make my view controller contain a page view controller using an embed segue. That handles the housekeeping of parent/child view controllers painlessly, or so I thought.

However, the client wants a page curl transition in the view controller, and it seems that you can't change the transition of a page view controller after initializing it, nor can you specify the navigation orientation, spine location, etc.

Hmm. Seems I am in a catch 22.

Does anybody know of a way to use an embed segue to embed a page view controller as a child of another view controller and control the settings you get with initWithTransitionStyle:navigationOrientation:options: ?

At this point I might need to abandon the embed segue and manage the parent/child view controller relationship manually, which is a fair amount of work, especially when you deal with forwarding auto-rotation and other messages from parent to child.


Solution

  • Ok, problem solved.

    There ARE settings in IB for a UIPageViewController that let you control the transition style, navigation orientation, and options.

    The problem is that when I created a container view in my parent view controller, IB created a generic UIViewController as the child and I changed it's type to UICollectionViewController. When I did that the settings stayed those for a generic UIViewController.

    I had to delete the generic child UIViewController that IB created, drag a UIPageViewController scene into the storyboard, then control-drag from the collection view onto my new UIPageViewController and select "embed" as the type of segue I wanted. When I did THAT, it gave me the settings I needed.