The solution is a template with the implementation of the basic methods of configuration and management of UIPageViewController.
The solution is designed for multi-level architectures, as it allows to distribute the code into the corresponding layers of the module.
- Create
ViewController
class with parentNKSlidesViewController
class
class ViewController: NKSlidesViewController { }
- Override properties
source: NKSlidesSource
andcontainer: UIView
for the ability to configure slide pages
class ViewController: NKSlidesViewController {
override var source: NKSlidesSource? { return ... }
override var container: UIView { return ... }
}
- Create type custom supporting
NKSlidesSource
protocol (if you use MVC you can implement protocol in ViewController class)
class Presenter: NKSlidesSource {
var viewer: NKSlideScreenViewable?
var initialPage: UIViewController {
//return UIViewController instance which must to be shown first on screen's display
return ...
}
func didPresent(_ page: UIViewController?) {
//any action after page was presented
}
func page(after viewController: UIViewController) -> UIViewController? {
//return UIViewController instance which must to be shown after passed page
return ...
}
func page(before viewController: UIViewController) -> UIViewController? {
//return UIViewController instance which must to be shown after passed page
return ...
}
}
- Add
Presenter
initialization toViewController
class ViewController: NKSlidesViewController {
override var source: NKSlidesSource? {
return presenter
// if you use MVC you can `return self`
}
override var container: UIView { return ... }
lazy var presenter = Presenter(self)
}
To run the example project, clone the repo, and run pod install
from the Example directory first.
iOS 10.0
Swift 5.0
NKSlideScreensTemplate is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'NKSlideScreensTemplate'
nkopilovskii, [email protected]
NKSlideScreensTemplate is available under the MIT license. See the LICENSE file for more info.