Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何删除Cocos2d中的图层?_Ios_Xcode_Release_Removechild - Fatal编程技术网

Ios 如何删除Cocos2d中的图层?

Ios 如何删除Cocos2d中的图层?,ios,xcode,release,removechild,Ios,Xcode,Release,Removechild,我的代码有什么问题 if(menu){ [menu removeAllChildrenWithCleanup:YES]; // 1 line [menu removeFromParentAndCleanup:YES]; // 2 line menu = nil; } 它失败了,但如果我评论第一行或第二行,一切都是好的。 但是如果我不清理子节点,它们就不会被清理,如果我不清理父节点的菜单,它就不会释放自己 我该怎么办 我想您可能想看看这个cleanup bool参数;

我的代码有什么问题

if(menu){
    [menu removeAllChildrenWithCleanup:YES]; // 1 line
    [menu removeFromParentAndCleanup:YES];   // 2 line
    menu = nil;
}
它失败了,但如果我评论第一行或第二行,一切都是好的。 但是如果我不清理子节点,它们就不会被清理,如果我不清理父节点的菜单,它就不会释放自己


我该怎么办

我想您可能想看看这个cleanup bool参数;)使用参数-YES和NO-all same=(从父级中删除菜单如何?我猜菜单的父级是self,因此看起来像这样[self-removeChild:menu cleanup:YES],谢谢帮助!问题出在父级中。我两次尝试删除一个对象。