How to best transition a book app that uses one UIViewController to handle all the pages as UIViews to StoryBoarding and UIPageView?

StackOverflow https://stackoverflow.com/questions/9356075

Question

I have a book app that has about 30 pages that are each a UIView in a single UIViewController. I want to transition this to an app that uses StoryBoarding and UIPageViews. It looks like each of the "pages" in UIPageView must be a UIViewController, not a UIView. What would be the best way of going about this? Do I need to make a UIViewController out of each UIView page?

Was it helpful?

Solution

Check out An Example iOS 5 iPhone UIPageViewController Application article. That chapter will provide a brief overview of the concepts behind the page view controller and an example application designed to demonstrate this class in action.

OTHER TIPS

Yep. Rewrite all your UIView subclasses as UIViewController subclasses. I've done it with a few of my projects, and it turns out to be just a little tedious. For my projects I found it easiest to just create a new Xcode project and build the new infrastructure. Then create new UIViewController classes for each of my old UIView classes. Then I copied and pasted most of the code from the old UIView classes into new UIViewController classes. I changed a lot of self to self.view. The life cycle of a UIViewController is a bit more complex than a UIView, so I ended up moving some initialization code from the designated initializer to the viewDidLoad and viewWillAppear methods in my UIViewController subclasses.

Response to comment: In my apps many pages have unique interactive features, so I write a unique UIViewController subclass to manage those features. Some pages will have the same features but different content. These will just use multiple instances of one UIViewController subclass. My model object will make these UIViewController subclasses and populate them with the appropriate content.

In other words, there's no need to write a new UIViewController subclass for every page. Only as many as you have unique functionality on a page. If your page doesn't do anything, you could even just use UIViewController without subclassing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top