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
|
import UIKit
|
||||||
|
|
||||||
class SegmentedPageViewController: UIPageViewController, UIPageViewControllerDataSource, UIPageViewControllerDelegate {
|
class SegmentedPageViewController: UIPageViewController, UIPageViewControllerDelegate {
|
||||||
|
|
||||||
let titles: [String]
|
let titles: [String]
|
||||||
let pageControllers: [UIViewController]
|
let pageControllers: [UIViewController]
|
||||||
|
@ -23,7 +23,6 @@ class SegmentedPageViewController: UIPageViewController, UIPageViewControllerDat
|
||||||
|
|
||||||
super.init(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
|
super.init(transitionStyle: .scroll, navigationOrientation: .horizontal, options: nil)
|
||||||
|
|
||||||
self.dataSource = self
|
|
||||||
self.delegate = self
|
self.delegate = self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,20 +53,7 @@ class SegmentedPageViewController: UIPageViewController, UIPageViewControllerDat
|
||||||
@objc func segmentedControlChanged() {
|
@objc func segmentedControlChanged() {
|
||||||
selectPage(at: segmentedControl.selectedSegmentIndex, animated: true)
|
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
|
// MARK: - Page View Controller Delegate
|
||||||
func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
|
func pageViewController(_ pageViewController: UIPageViewController, didFinishAnimating finished: Bool, previousViewControllers: [UIViewController], transitionCompleted completed: Bool) {
|
||||||
currentIndex = pageControllers.firstIndex(of: viewControllers!.first!)!
|
currentIndex = pageControllers.firstIndex(of: viewControllers!.first!)!
|
||||||
|
|
Loading…
Reference in New Issue