Skip to content

Instantly share code, notes, and snippets.

@stuffmc
Created March 29, 2013 15:54
Show Gist options
  • Save stuffmc/5271713 to your computer and use it in GitHub Desktop.
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.
- (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