TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Michael Kamphausen, cg, Tino Rachui, Mathias Köhnke, Mathias Koehnke, Nico Schümann, Heiko Wichmann, Stephan Lerner, Famara Kassama.
APLPageViewControllerDataSource provides an index based API on top of the viewControllerBeforeViewController and viewControllerAfterViewController API of UIPageViewController.
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;
Tobias Conradi, [email protected]
APLPageViewControllerDataSource is available under the MIT license. See the LICENSE file for more info.