diff --git a/EMPageViewController/EMPageViewController.swift b/EMPageViewController/EMPageViewController.swift index a5e3ae9..c38592e 100644 --- a/EMPageViewController/EMPageViewController.swift +++ b/EMPageViewController/EMPageViewController.swift @@ -170,7 +170,7 @@ open class EMPageViewController: UIViewController, UIScrollViewDelegate { /// The direction the page controller is scrolling towards. open private(set) var navigationDirection: EMPageViewControllerNavigationDirection? - private var adjustingContentOffset = false // Flag used to prevent isScrolling delegate when shifting scrollView + public var adjustingContentOffset = false // Flag used to prevent isScrolling delegate when shifting scrollView private var loadNewAdjoiningViewControllersOnFinish = false private var didFinishScrollingCompletionHandler: ((_ transitionSuccessful: Bool) -> Void)? private var transitionAnimated = false // Used for accurate view appearance messages diff --git a/Examples/Greetings-ObjC/Greetings-ObjC/RootViewController.m b/Examples/Greetings-ObjC/Greetings-ObjC/RootViewController.m index 172a83a..ad366fd 100644 --- a/Examples/Greetings-ObjC/Greetings-ObjC/RootViewController.m +++ b/Examples/Greetings-ObjC/Greetings-ObjC/RootViewController.m @@ -188,5 +188,26 @@ - (void)em_pageViewController:(EMPageViewController *)pageViewController didFini } +- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id )coordinator { + [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; + // Code here will execute before the rotation begins. + // Equivalent to placing it in the deprecated method -[willRotateToInterfaceOrientation:duration:] + + // Disable scrolling in our swipe navigation to prevent layout issues. + [self.pageViewController.scrollView setScrollEnabled:NO]; + self.pageViewController.adjustingContentOffset = YES; + NSLog(@"ROTATING WILL START"); + [coordinator animateAlongsideTransition:^(id context) { + + } completion:^(id context) { + // Code here will execute after the rotation has finished. + // Equivalent to placing it in the deprecated method -[didRotateFromInterfaceOrientation:] + + // Enable scrolling once rotating finishes so we can use swipe navigation. + [self.pageViewController.scrollView setScrollEnabled:YES]; + self.pageViewController.adjustingContentOffset = NO; + NSLog(@"ROTATING FINISHED "); + }]; +} @end