I am adding and removing a CCScrollView to and from a CCNode as so:
-(void)openShop
{
CCNode *shopNode = [CCBReader loadAsScene:@"Shop"];
CCScrollView *scroll = [[CCScrollView alloc]initWithContentNode:shopNode];
if (visible == NO) {
[shopNode setContentSizeInPoints:(CGSizeMake(320, 1000))];
[scrollContainer addChild:scroll];
[scroll setContentSizeInPoints:(CGSizeMake(320.0, 370.0))];
[scroll setHorizontalScrollEnabled:NO];
[scroll setPosition:(CGPointMake(0, 70))];
[scroll setScrollPosition:(CGPointMake(0, 0))];
visible = YES;
} else {
[scrollContainer removeChild:scroll];
visible = NO;
}
}
Everything displays fine, but when I run openShop to removeChild:scroll the program crashes and returns this error: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'This node does not contain the specified child.' I don't understand because scroll is obviously added to the child.. So how can scrollContainer not contain scroll?
[scroll removeFromParentAndCleanup:YES]doesn't crash the program anymore, but the scrollview doesn't disappear. I set up a breakpoint, but should I be looking for? Thanks - SaleenS7scrollContainer? - i_am_jorfscrollContainerother thanscrollwhen it is added in the code above - SaleenS7