Custom horizontal slide page view controller.
一款自定义的横滑样式分页控制器,能够保证 ChildViewController 的生命周期方法可以正确的被调用,支持动画形式的 index 切换Swift 4.2 & iOS 9+.
To run the example project, clone the repo, and run pod install
from the Example directory first.
let pageController = MERPageViewController()
pageController.delegate = self
pageController.dataSource = self
pageController.pageBounces = false
// Automatically loads adjacent pages when you stop
// pageController.isPreloadEnabled = true
If you need to use Reusable UIViewController
class AnyViewController: UIViewController, MERPageReusable { }
pageController.register(AnyViewController.self)
Required dataSource
#pragma mark ----------------- MERPageViewControllerDataSource -----------------
func numberOfControllers(in controller: MERPageViewController) -> Int {
dataArray.count
}
func mer_pageViewController(_ controller: MERPageViewController, controllerAt index: Int) -> UIViewController {
/// If you need to use Reusable UIViewController
let child: AnyViewController = controller.dequeueReusableChild(for: index)
child.title = dataArray[index]
return child
}
MERPageViewController is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'MERPageViewController'
👤 Mervin1024 [email protected]
MERPageViewController is available under the MIT license. See the LICENSE file for more info.