This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation ViewController | |
#pragma mark View Lifecycle | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
[self createPageViewController]; | |
[self setupPageControl]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - View Lifecycle | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
createPageViewController() | |
setupPageControl() | |
} | |
private func createPageViewController() { | |
let pageController = self.storyboard!.instantiateViewControllerWithIdentifier("PageController") as! UIPageViewController |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark UIPageViewControllerDataSource | |
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController | |
{ | |
PageItemController *itemController = (PageItemController *)viewController; | |
if (itemController.itemIndex > 0) | |
{ | |
return [self itemControllerForIndex:itemController.itemIndex-1]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - UIPageViewControllerDataSource | |
func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -> UIViewController? { | |
let itemController = viewController as! PageItemController | |
if itemController.itemIndex > 0 { | |
return getItemController(itemController.itemIndex-1) | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma mark Page Indicator | |
- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController | |
{ | |
return [_contentImages count]; | |
} | |
- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController | |
{ | |
return 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Page Indicator | |
func presentationCountForPageViewController(pageViewController: UIPageViewController) -> Int { | |
return contentImages.count | |
} | |
func presentationIndexForPageViewController(pageViewController: UIPageViewController) -> Int { | |
return 0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UIViewController *)currentController | |
{ | |
if ([self.pageViewController.viewControllers count]) | |
{ | |
return self.pageViewController.viewControllers[0]; | |
} | |
return nil; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func currentController() -> UIViewController? { | |
if self.pageViewController?.viewControllers?.count > 0 { | |
return self.pageViewController?.viewControllers![0] | |
} | |
return nil | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func currentControllerIndex() -> Int { | |
let pageItemController = self.currentController() | |
if let controller = pageItemController as? PageItemController { | |
return controller.itemIndex | |
} | |
return -1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSUInteger)currentControllerIndex | |
{ | |
PageItemController *pageItemController = (PageItemController *) [self currentController]; | |
if (pageItemController) | |
{ | |
return pageItemController.itemIndex; | |
} | |
return -1; |