Created
March 29, 2013 15:54
-
-
Save stuffmc/5271713 to your computer and use it in GitHub Desktop.
RAPageViewControllerSubclass code necessary for getting scrollsToTop back at work. Unless @evadne sees a better solution.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad { | |
[super viewDidLoad]; | |
[self scrollView].scrollsToTop = NO; | |
[self scrollView].delegate = self; | |
... | |
} | |
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView | |
{ | |
[super scrollViewDidEndDecelerating:scrollView]; | |
[self setScrollsToTopForViewControllersTopViewControllerView:self.previousPageViewController]; | |
[self setScrollsToTopForViewControllersTopViewControllerView:self.currentPageViewController]; | |
[self setScrollsToTopForViewControllersTopViewControllerView:self.nextPageViewController]; | |
} | |
- (void)setScrollsToTopForViewControllersTopViewControllerView:(UIViewController*)viewController | |
{ | |
[self viewControllersTopViewControllerView:viewController scrollsToTop:(viewController == self.currentPageViewController)]; | |
} | |
- (void)viewControllersTopViewControllerView:(UIViewController*)viewController scrollsToTop:(BOOL)scrollsToTop | |
{ | |
if ([viewController isKindOfClass:[UINavigationController class]]) { | |
UINavigationController *navigationController = (UINavigationController*)viewController; | |
if ([navigationController.topViewController.view isKindOfClass:[UIScrollView class]]) { | |
((UIScrollView*)navigationController.topViewController.view).scrollsToTop = scrollsToTop; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment