I try to add CCScrollView with paging (cocos2d- iphone v3.0). But it's not working. It doesn't call any delegate methods (for example scrollViewDidScroll:).
CCNode *cards = [CCNode node];
for (int i = 0 ; i < 3; i++) {
CCLabelTTF *label = [CCLabelTTF labelWithString:[NSString stringWithFormat:@"label %d", i] fontName:@"Arial" fontSize:24];
label.color = [CCColor redColor];
label.position = ccp(winSize.width * i + winSize.width * 0.5 , winSize.height * 0.5);
[cards addChild:label];
}
self.scrollView = [[CCScrollView alloc] initWithContentNode:cards];
self.scrollView.contentSizeType = CCSizeTypeNormalized;
self.scrollView.contentSize = CGSizeMake(3, 1);
self.scrollView.pagingEnabled = YES;
self.scrollView.delegate = self;
self.scrollView.position = CGPointZero;
self.scrollView.anchorPoint = CGPointZero;
[self addChild:self.scrollView];
You actually need to set the
contentSize
of thecontentNode
of thescrollView
as opposed to thecontentSize
of thescrollView
.In
CCScrollView.h
So you should replace this part of the code:
With this: