Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

Commit

Permalink
Fixes a bug in which the pageAppeared delegate method is not called a…
Browse files Browse the repository at this point in the history
…fter tapping a page

This resolves [Issue ealeksandrov#174: Delegate method pageAppeared doesn't being called]
  • Loading branch information
JakeSc committed Jul 18, 2016
1 parent 75a5eaf commit 52f7cdd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions EAIntroView/EAIntroView.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,7 @@ typedef NS_ENUM(NSUInteger, EAViewAlignment) {
- (void)setCurrentPageIndex:(NSUInteger)currentPageIndex;
- (void)setCurrentPageIndex:(NSUInteger)currentPageIndex animated:(BOOL)animated;


- (void)scrollToPageForIndex:(NSUInteger)newPageIndex animated:(BOOL)animated;

@end
16 changes: 14 additions & 2 deletions EAIntroView/EAIntroView.m
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,17 @@ - (void)setCurrentPageIndex:(NSUInteger)currentPageIndex animated:(BOOL)animated

_currentPageIndex = currentPageIndex;

CGFloat offset = currentPageIndex * self.scrollView.frame.size.width;
[self scrollToPageForIndex:currentPageIndex animated:animated];
}

- (void)scrollToPageForIndex:(NSUInteger)newPageIndex animated:(BOOL)animated
{
if(![self pageForIndex:newPageIndex]) {
NSLog(@"Wrong newPageIndex received: %ld",(long)newPageIndex);
return;
}

CGFloat offset = newPageIndex * self.scrollView.frame.size.width;
CGRect pageRect = { .origin.x = offset, .origin.y = 0.0, .size.width = self.scrollView.frame.size.width, .size.height = self.scrollView.frame.size.height };
[self.scrollView scrollRectToVisible:pageRect animated:animated];

Expand All @@ -1023,7 +1033,9 @@ - (IBAction)goToNext:(id)sender {
if(self.currentPageIndex + 1 >= [self.pages count]) {
[self hideWithFadeOutDuration:0.3];
} else {
[self setCurrentPageIndex:self.currentPageIndex + 1 animated:YES];
// Just scroll to the new page.
// After scrolling ends, we call -checkIndexForScrollView:, which itself sets the new currentPageIndex.
[self scrollToPageForIndex:self.currentPageIndex + 1 animated:YES];
}
}

Expand Down

0 comments on commit 52f7cdd

Please sign in to comment.