If I add a UITextField to the openGLView and remove it again, dealloc is never called.
// add a textfield to the openGLView
codeTextfield = [[UITextField alloc] initWithFrame:cod开发者_如何学运维eTextfieldFrame];
[[[CCDirector sharedDirector] openGLView] addSubview:codeTextfield];
// remove the textfield
[codeTextfield removeFromSuperview];
// call replaceScene
[CCDirector sharedDirector] replaceScene:[Menu node]];
// dealloc will not be called
I suffer with this problem a long time and there is no solution in sight.
Check the retain counts along the way; this should help you to see what's going on.
codeTextfield = [[UITextField alloc] initWithFrame:codeTextfieldFrame];
// RETAIN COUNT IS NOW 1
[[[CCDirector sharedDirector] openGLView] addSubview:codeTextfield];
// RETAIN COUNT IS NOW 2
[codeTextfield removeFromSuperview];
// RETAIN COUNT IS NOW 1
To get the count back to 0 after removing codeTextfield from the view, instead do this:
codeTextfield = [[UITextField alloc] initWithFrame:codeTextfieldFrame];
// RETAIN COUNT IS NOW 1
[[[CCDirector sharedDirector] openGLView] addSubview:codeTextfield];
// RETAIN COUNT IS NOW 2
[codeTextfield release];
// RETAIN COUNT IS NOW 1
[codeTextfield removeFromSuperview];
// RETAIN COUNT IS NOW 0 -- DEALLOC WILL BE CALLED
addSubview retains the view.  As you created the object with alloc, you own it too.  Removing the view will only decrease the retain count by 1.  You want [codeTextfield release] after you add it as a subview.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论