The EventsController and Its PageViewController

At the start of this chapter, I promised to show you how to enable users to turn the page between one view controller and another. To implement this cool page-turning stuff, you need a UIPageViewController. You create that in the EventsController in its viewDidLoad method.

To start, though, you need to make the EventsController a UIPageView Controller data source and delegate. (Actually, in this implementation you won’t need to use any of the delegate methods, but it’s good for you to know about them.) Add the bolded code in Listing 16-11 (which includes the declaration of another method that you’ll use shortly) to EventsController.h.

Listing 16-11: Updating the EventsController Interface

#import “RTDetailViewController.h”

@class EventPageController;

@interface EventsController : RTDetailViewController

<UIPageViewControllerDelegate,

UIPageViewControllerDataSource>

- (EventPageController *)viewControllerAtIndex:

(NSUInteger)index storyboard:(UIStoryboard *)storyboard;

@end

Now read on to learn about the data source and delegate.

Data sources and delegates

You’ve used delegates a few times already, such as when you add the code to the app delegate in Chapter 8. A data source is really just another kind of delegate that supplies the data that a framework object needs. In Chapter 20, when you implement a dynamic Table view, you do that as well, and data sources are also used in many other places in the framework — in picker ...

Get iPad Application Development For Dummies, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.