diff --git a/Source/CourseContentPageViewController.swift b/Source/CourseContentPageViewController.swift index 57658d184..b982eb652 100644 --- a/Source/CourseContentPageViewController.swift +++ b/Source/CourseContentPageViewController.swift @@ -116,7 +116,8 @@ public class CourseContentPageViewController : UIPageViewController, UIPageViewC // Filed http://www.openradar.appspot.com/radar?id=6188034965897216 against Apple to better expose // this API. // Verified on iOS9 and iOS 8 - if let scrollView = (view.subviews.compactMap { return $0 as? UIScrollView }).first { + if let scrollView = view.subviews.compactMap({ return $0 as? UIScrollView }).first { + scrollView.delegate = self scrollView.delaysContentTouches = false } addObservers() @@ -515,6 +516,19 @@ public class CourseContentPageViewController : UIPageViewController, UIPageViewC } } +// There is a bug with UIPageViewController, if user tries to quickly scroll between controllers, +// the UIPageViewControllerDelegate is not being called appropriately, +// to handle this, listen to UISsrollViewDelegate and handle the user interaction. +extension CourseContentPageViewController: UIScrollViewDelegate { + public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { + updateTransitionState(is: false) + } + + public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { + updateTransitionState(is: false) + } +} + // MARK: Testing extension CourseContentPageViewController { public func t_blockIDForCurrentViewController() -> OEXStream {