Component inspired by UIPageController that allows fast navigation by scrolling to switch to a different ViewController. ViewControllers are lazily instantiated the first time it gets activated.
An item gets automatically selected if the user stop scrolling, or the user can tap an element o select it.
To run the example project, clone the repo, and run pod install
from the Example directory first.
- iOS >= 9.0
- Swift 3.0
MultiPageController is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "MultiPageController"
Set the MultipageController's datasource and reload it's data:
let multipageController = MultipageController()
multipageController.dataSource = self
multipageController.reloadData()
/*
* Returns the number of items to be presented when scrolling
*/
func numberOfItems(in: MultiPageController) -> Int
/*
* Returns a view to be used as preview of the item the user can select.
* This is called only once per element.
*/
func multiPageController(_ multiPageController: MultiPageController, viewControllerAt index: Int) -> UIViewController
/*
* Returns the view controller to be presented when the user taps selects an element.
* This is called once the user first selects the element at the specified index
*/
func multiPageController(_ multiPageController: MultiPageController, previewViewAt index: Int) -> UIView
Rafael Martins, [email protected]
MultiPageController is available under the MIT license. See the LICENSE file for more info.