APLPageViewControllerDataSource is an array based data source for UIPageViewController.
Objective-C Ruby Shell C C++
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
APLPageViewControllerDataSourceDemo
Classes/ios
.gitignore
APLPageViewControllerDataSource.podspec
CHANGELOG.md
LICENSE
README.md
Rakefile

README.md

APLPageViewControllerDataSource

Version Platform

APLPageViewControllerDataSource provides an index based API on top of the viewControllerBeforeViewController and viewControllerAfterViewController API of UIPageViewController.

Installation

APLPageViewControllerDataSource is available through CocoaPods, to install it simply add the following line to your Podfile:

pod "APLPageViewControllerDataSource"

Usage

Import header file:

#import "APLPageViewControllerDataSource.h"

Declare a dataSource property:

@property (nonatomic) APLPageViewControllerDataSource *dataSource;

Create a APLPageViewControllerDataSource instance and configure it:

    APLPageViewControllerDataSource *pageViewControllerDataSource = [APLPageViewControllerDataSource new];
    pageViewControllerDataSource.delegate = self;
    pageViewControllerDataSource.pageViewController = pageViewController;
    pageViewControllerDataSource.objects = @[] // your data objects
    self.dataSource = pageViewControllerDataSource;

Declare the protocol methods required to configure the view controller

- (UIViewController*)pageViewControllerDataSource:(APLPageViewControllerDataSource *)dataSource contentViewControllerForIndex:(NSUInteger)index {
    APLContentViewController *detailViewController = [APLContentViewController instantiateFromStoryboard]; // use your own content view controller class
    detailViewController.item = dataSource.objects[index]; // configure your view controller
    return detailViewController;
}

- (NSUInteger)pageViewControllerDataSource:(APLPageViewControllerDataSource *)dataSource indexForContentViewController:(UIViewController *)viewController {
    APLContentViewController *detailViewController = (APLContentViewController*)viewController;
    return [dataSource.objects indexOfObject:detailViewController.item];
}

When you retrieve new data, update your dataSource like this:

self.dataSource.objects = newObjects;

Author

Tobias Conradi, tconradi@apploft.de

License

APLPageViewControllerDataSource is available under the MIT license. See the LICENSE file for more info.