From d3e31541cf7c18eb415c207587aa6ba28c6c6249 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 14 Sep 2019 15:59:17 -0400 Subject: [PATCH] Don't allow swiping in SegmentedPageViewController --- .../SegmentedPageViewController.swift | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/Tusker/Screens/Utilities/SegmentedPageViewController.swift b/Tusker/Screens/Utilities/SegmentedPageViewController.swift index c3235b47..636c5798 100644 --- a/Tusker/Screens/Utilities/SegmentedPageViewController.swift +++ b/Tusker/Screens/Utilities/SegmentedPageViewController.swift @@ -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!)!