Wrapping the Implementation

Like table views, a page view controller uses a delegate and data source to set the behavior and contents of its presentation. Unlike with table views, it’s simplest to wrap these items into a custom class to hide their details from applications. The code needed to support a page view implementation is rather quirky—but highly reusable. A wrapper lets you turn your attention away from fussy coding details to specific content-handling concerns.

In the standard implementation, the data source is responsible for providing page controllers on demand. It returns the next and previous view controllers in relationship to a given one. The delegate handles reorientation events and animation callbacks, setting the page view ...

Get The Core iOS Developer’s Cookbook, Fifth 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.