MatthewYork / iPhone-IntroductionTutorial

A "drop-in" solution for building stylish app introductions and tutorials.
MIT License
774 stars 116 forks source link

Clicking Page Control does not change panel #3

Closed wuf810 closed 11 years ago

wuf810 commented 11 years ago

Clicking a page control highlights the page control but does not navigate to that associated "panel". Looking at your code I can't see anywhere where you've created an action for the page control. This seems odd and wrong. Am I missing something here?

wuf810 commented 11 years ago

Ok something like this should work. Could you add it Matthew?

Add the following line just before the PageControl is added to the view:

[self.PageControl addTarget:self action:@selector(showPanelAtPageControl) forControlEvents:UIControlEventValueChanged];

Then add a new method to respond to these events:

-(void)showPanelAtPageControl {

LastPanelIndex = self.PageControl.currentPage;
self.CurrentPanelIndex = self.PageControl.currentPage;

//Format and show new content
[self setContentScrollViewHeightForPanelIndex:self.CurrentPanelIndex animated:YES];
[self makePanelVisibleAtIndex:(NSInteger)self.CurrentPanelIndex];

[self.ContentScrollView setContentOffset:CGPointMake(self.CurrentPanelIndex * 320, 0) animated:YES];
//Call Back, if applicable
if (LastPanelIndex != self.CurrentPanelIndex) { //Keeps from making the callback when just bouncing and not actually changing pages
    if ([(id)delegate respondsToSelector:@selector(introductionDidChangeToPanel:withIndex:)]) {
        [delegate introductionDidChangeToPanel:Panels[self.CurrentPanelIndex] withIndex:self.CurrentPanelIndex];
    }
}

}

MatthewYork commented 11 years ago

Yeah, that's definitely a bug. Good find! I'll work on this when I can, and try to credit you in the code for it.

wuf810 commented 11 years ago

Thanks. I subclassed your class and applied the above changes and they seem to work...so please just go ahead and use as you see fit. Thanks, M.

yinsee commented 11 years ago

please merge my pull request which i have included wuf810's solution

MatthewYork commented 11 years ago

Clicking the dots takes you to the next or previous panel, but does not allow one to skip a panel. I feel this is good, so I am going to close this issue.