From c10b252ddcd509e5b6bd8bf9d6b86e73b7f7dd70 Mon Sep 17 00:00:00 2001 From: Joe Turner Date: Fri, 11 Sep 2015 08:54:18 -0700 Subject: [PATCH] Fix an issue where setContentOffset:animated: with animated=NO can actually call scrollViewDidEndScrollingAnimation:, which results in trying to set the page to -1. This was causing some weird behavior --- src/pagingscrollview/src/NIPagingScrollView.m | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pagingscrollview/src/NIPagingScrollView.m b/src/pagingscrollview/src/NIPagingScrollView.m index dcc7ce8a7..9cfcc79a3 100644 --- a/src/pagingscrollview/src/NIPagingScrollView.m +++ b/src/pagingscrollview/src/NIPagingScrollView.m @@ -491,10 +491,12 @@ - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { } - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView { - [self didAnimateToPage:_animatingToPageIndex]; + if (_animatingToPageIndex >= 0) { + [self didAnimateToPage:_animatingToPageIndex]; - if ([self.delegate respondsToSelector:_cmd]) { - [self.delegate scrollViewDidEndScrollingAnimation:scrollView]; + if ([self.delegate respondsToSelector:_cmd]) { + [self.delegate scrollViewDidEndScrollingAnimation:scrollView]; + } } }