From 02d9a87417837ffda602b2d06c2c6897d15a1202 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Tue, 23 Aug 2011 09:24:14 -0400 Subject: Added a UIPageControl to the level selection screen The page control updates when you swipe through the levels, but tapping it does nothing. I initially attempted to implement scrolling by tapping on the page control, but for some reason, it worked perfectly in the simulator and only randomly on the iPhone. Very weird. Refs #207 --- Classes/CocosOverlayScrollView.m | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Classes/CocosOverlayScrollView.m') diff --git a/Classes/CocosOverlayScrollView.m b/Classes/CocosOverlayScrollView.m index dcf5571..dee9dfe 100755 --- a/Classes/CocosOverlayScrollView.m +++ b/Classes/CocosOverlayScrollView.m @@ -12,7 +12,7 @@ @synthesize targetLayer; // Configure your favorite UIScrollView options here --(id) initWithFrame: (CGRect) frameRect numPages: (int) numPages width: (float) width layer: (CCNode*) layer { +-(id) initWithFrame: (CGRect) frameRect numPages: (int) numPages width: (float) width layer: (CCNode*) layer pageControl:(UIPageControl *)m_pageControl{ if ((self = [super initWithFrame: frameRect])){ self.contentSize = CGSizeMake(width*numPages, 320); self.bounces = YES; @@ -26,6 +26,7 @@ [self setScrollEnabled:TRUE]; self.targetLayer = layer; // self.canCancelContentTouches = YES; + pageControl = m_pageControl; } return self; } @@ -96,4 +97,10 @@ self.targetLayer = nil; [super dealloc]; } + +- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView +{ + [pageControl setCurrentPage:(NSUInteger)([scrollView contentOffset].x / [scrollView frame].size.width)]; +} + @end \ No newline at end of file -- cgit 1.4.1