English 中文(简体)
Cannot release UIView in cocos2d
原标题:Cannot release UIView in cocos2d

我从网上的某个地方抽取这一样本。

我的档案包括:

@interface PopupWindowString : CCNode <UITextFieldDelegate> {
    UIView *landscapeView;
    UITextField *username;
}

和我手法中的档案有:

landscapeView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
CGAffineTransform tr = landscapeView.transform;
tr = CGAffineTransformRotate(tr, (M_PI * -2.0));
landscapeView.transform = tr;
landscapeView.center = [[CCDirector sharedDirector] openGLView].center;

username = [[UITextField alloc] initWithFrame:CGRectMake(160, 100, 160, 90)];
[username setTextAlignment:UITextAlignmentCenter];
[username setDelegate:self];
[username setPlaceholder:@"New name"];
[username setTextColor:[UIColor colorWithRed:255 green:255 blue:255 alpha:1.0]];
[landscapeView addSubview:username];

[[[CCDirector sharedDirector] openGLView] addSubview:landscapeView];

一切都是冷静的,但当我结束流行性交易时,没有人叫他。

看来,在《地貌观察法》颁布后,仍保留着“Count”:

[username release];

[username removeFromSuperview];

[landscapeView release];

[landscapeView removeFromSuperview];

我不知道与它做什么。 我没有别的地方,我只在这里使用地貌语。

我试图将《国际律师联合会意见》分门别类,试图从保留和释放到什么地方,并在此列出:

1. 会议开幕:

  1. Retain call from my PopupWindowString init method
  2. Retain from [CALayer layoutSublayers]
  3. Release from CALayerLayoutIfNeeded

填满:

  1. retain from [__NSArrayM addObject] in [UIView(Hierarchy) subviews]
  2. release from my code [the one I pasted previously]
  3. release from my code [remove from subview]

As you can see one release is missing. I think, when closing the popup, this first retain is caused by me touching the view. However it is never released.

任何人都知道如何独一无二。

Thanks, Krystian

最佳回答

If you are balancing all of the retains implied or directly called with releases, then your job is done.

你们是否知道该物体被泄露? 您如何确定(注:retainCount从来不是正确的答案)?

作为书面材料,该代码似乎并不泄露landinskiView。 请注意,如果该代码不能载于dealloc,你就希望将<条码>陆替代号<>/条码>至零时防止坠毁。 观点发布],载于dealloc

问题回答

暂无回答




相关问题
Asynchronous request to the server from background thread

I ve got the problem when I tried to do asynchronous requests to server from background thread. I ve never got results of those requests. Simple example which shows the problem: @protocol ...

objective-c: Calling a void function from another controller

i have a void, like -(void) doSomething in a specific controller. i can call it in this controller via [self doSomething], but i don t know how to call this void from another .m file. I want to call ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

NSUndoManager and runModalForWindow:

I have a simple Core Data app which displays a list of entities in the main window. To create or add new entities, I use a second modal window with a separate managed object context so changes can be ...

NSMutableArray values becoming "invalid"

I m trying to show a database information in a tableview and then the detailed information in a view my problem is as follow: I created a NSMutableArray: NSMutableArray *myArray = [[NSMutableArray ...

iPhone numberpad with decimal point

I am writing an iPhone application which requires the user to enter several values that may contain a decimal point (currency values, percentages etc.). The number of decimal places in the values ...

热门标签