Skip to content

Instantly share code, notes, and snippets.

@RShergold
Last active August 29, 2015 14:21
Show Gist options
  • Save RShergold/ff04fb705410c91726bb to your computer and use it in GitHub Desktop.
Save RShergold/ff04fb705410c91726bb to your computer and use it in GitHub Desktop.
PageViewController minimal
import UIKit
class ViewController: UIPageViewController, UIPageViewControllerDataSource {
var pages = [UIViewController]()
override func viewDidLoad() {
super.viewDidLoad()
self.dataSource = self
pages = [
self.storyboard?.instantiateViewControllerWithIdentifier("vc1") as! UIViewController
, self.storyboard?.instantiateViewControllerWithIdentifier("vc2") as! UIViewController
, self.storyboard?.instantiateViewControllerWithIdentifier("vc3") as! UIViewController
]
self.setViewControllers([pages.first!], direction: .Forward, animated: false, completion: nil)
}
func pageViewController(pageViewController: UIPageViewController, viewControllerBeforeViewController viewController: UIViewController) -> UIViewController? {
return ( pages.first == viewController ) ? nil : pages[ find(pages, viewController)!-1 ]
}
func pageViewController(pageViewController: UIPageViewController, viewControllerAfterViewController viewController: UIViewController) -> UIViewController? {
return ( pages.last == viewController ) ? nil : pages[ find(pages, viewController)!+1 ]
}
}
@RShergold
Copy link
Author

Reminder to self. This is a really bad idea. Memory 'n all that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment