Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delegate method pageAppeared doesn't being called #174

Closed
aleufms opened this issue Jun 28, 2016 · 3 comments
Closed

Delegate method pageAppeared doesn't being called #174

aleufms opened this issue Jun 28, 2016 · 3 comments
Labels

Comments

@aleufms
Copy link

aleufms commented Jun 28, 2016

The method func intro(introView: EAIntroView!, pageAppeared page: EAIntroPage!, withIndex pageIndex: UInt) doesn't being called when we use the funcion setCurrentPageIndex:animated

@aleufms aleufms changed the title Delegate method pageAppeared don't be calling Delegate method pageAppeared doesn't being called Jun 28, 2016
@JakeSc
Copy link
Contributor

JakeSc commented Jul 18, 2016

This is because the method setCurrentPageIndex:animated: sets self.currentPageIndex before scrolling:

    _currentPageIndex = currentPageIndex;

And then, in the scrollViewDidEndScrollingAnimation: delegate method, it calls the following code:

    [self notifyDelegateWithPreviousPage:self.currentPageIndex andCurrentPage:newPageIndex];
    _currentPageIndex = newPageIndex;

This notifyDelegate method has a check:

    if(currentPageIndex!=_currentPageIndex && currentPageIndex < _pages.count) {
        [call delegate]

Because the setCurrentPageIndex:animated method already set the _currentPageIndex ivar, this notifyDelegate check fails.

In general, I would recommend against custom setters that have side-effects. So we would have a (mostly empty) setter for setCurrentPageIndex:, and a separate method that performs the scrolling (like scrollToPageIndex:).

@JakeSc
Copy link
Contributor

JakeSc commented Jul 18, 2016

I'm able to reproduce this as well by using tapToNext and tapping on the pages.

JakeSc added a commit to life360-old/EAIntroView that referenced this issue Jul 18, 2016
…fter tapping a page

This partially resolves [Issue ealeksandrov#174: Delegate method pageAppeared doesn't being called]
JakeSc added a commit to life360-old/EAIntroView that referenced this issue Jul 18, 2016
…fter tapping a page

This partially resolves [Issue ealeksandrov#174: Delegate method pageAppeared doesn't being called]
JakeSc added a commit to life360-old/EAIntroView that referenced this issue Jul 18, 2016
…fter tapping a page

This resolves [Issue ealeksandrov#174: Delegate method pageAppeared doesn't being called]
@JakeSc
Copy link
Contributor

JakeSc commented Jul 18, 2016

Okay, I fixed this in #177 . You can call scrollToPageForIndex:animated: to switch pages, and it should hit the delegate method.

JakeSc added a commit to life360-old/EAIntroView that referenced this issue Jul 18, 2016
…fter tapping a page

This resolves [Issue ealeksandrov#174: Delegate method pageAppeared doesn't being called]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants