diff --git a/PagingScrollView.swift b/PagingScrollView.swift new file mode 100644 index 00000000..ade803c8 --- /dev/null +++ b/PagingScrollView.swift @@ -0,0 +1,22 @@ +// +// PagingScrollView.swift +// Pods +// +// Created by dudongge on 2018/2/5. +// + +import UIKit +//Add the system's return gesture. +class PagingScrollView: UIScrollView { + + override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool { + if gestureRecognizer.isKind(of: UIPanGestureRecognizer.self) { + let pan: UIPanGestureRecognizer = gestureRecognizer as! UIPanGestureRecognizer + if pan.translation(in: self).x > 0.0 && self.contentOffset.x == 0.0 { + return false + } + } + return super.gestureRecognizerShouldBegin(gestureRecognizer) + } + +} diff --git a/Pod/Classes/PagingViewController.swift b/Pod/Classes/PagingViewController.swift index c82a8c3d..4bc5885f 100644 --- a/Pod/Classes/PagingViewController.swift +++ b/Pod/Classes/PagingViewController.swift @@ -13,7 +13,7 @@ open class PagingViewController: UIViewController { public internal(set) var currentViewController: UIViewController! public fileprivate(set) var visibleControllers = [UIViewController]() - internal let contentScrollView: UIScrollView = { + internal let contentScrollView: PagingScrollView = { $0.isPagingEnabled = true $0.isDirectionalLockEnabled = true $0.showsHorizontalScrollIndicator = false @@ -22,7 +22,7 @@ open class PagingViewController: UIViewController { $0.bounces = false $0.translatesAutoresizingMaskIntoConstraints = false return $0 - }(UIScrollView(frame: .zero)) + }(PagingScrollView(frame: .zero)) fileprivate let options: PagingMenuControllerCustomizable fileprivate var currentIndex: Int = 0 @@ -301,3 +301,5 @@ extension PagingViewController { return true } } + +