forked from shadowfacts/Tusker
Don't allow swiping in SegmentedPageViewController
This commit is contained in:
parent
88344c67e8
commit
d3e31541cf
|
@ -8,7 +8,7 @@
|
|||
|
||||
import UIKit
|
||||
|
||||
class SegmentedPageViewController: UIPageViewController, UIPageViewControllerDataSource, UIPageViewControllerDelegate {
|
||||
class SegmentedPageViewController: UIPageViewController, UIPageViewControllerDelegate {
|
||||
|
||||
let titles: [String]
|
||||
let pageControllers: [UIViewController]
|
||||
|
@ -23,7 +23,6 @@ class SegmentedPageViewController: UIPageViewController, UIPageViewControllerDat
|
|||
|
||||
super.init(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
|
||||
|
||||
self.dataSource = self
|
||||
self.delegate = self
|
||||
}
|
||||
|
||||
|
@ -54,20 +53,7 @@ class SegmentedPageViewController: UIPageViewController, UIPageViewControllerDat
|
|||
@objc func segmentedControlChanged() {
|
||||
selectPage(at: segmentedControl.selectedSegmentIndex, animated: true)
|
||||
}
|
||||
|
||||
// MARK: - Page View Controller Data Source
|
||||
func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: UIViewController) -> UIViewController? {
|
||||
guard let index = pageControllers.firstIndex(of: viewController),
|
||||
index > 0 else { return nil }
|
||||
return pageControllers[index - 1]
|
||||
}
|
||||
|
||||
func pageViewController(_ pageViewController: UIPageViewController, viewControllerAfter viewController: UIViewController) -> UIViewController? {
|
||||
guard let index = pageControllers.firstIndex(of: viewController),
|
||||
index < pageControllers.count - 1 else { return nil }
|
||||
return pageControllers[index + 1]
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Page View Controller Delegate
|
||||
func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
|
||||
currentIndex = pageControllers.firstIndex(of: viewControllers!.first!)!
|
||||
|
|
Loading…
Reference in New Issue