English 中文(简体)
发表在“i”[复制]的意见
原标题:releasing views in iPhone [duplicate]
This question already has answers here:
Closed 11 years ago.

Possible Duplicate:
calling [myString release] does NOT decrement [myString retainCount]

我面临很大的问题,请帮助我解决同样的问题。

我正在以习俗方式提出看法。

   UIView *view = [self getCustomVIew:index];
   [view release];
   view = nil;

getCustomVIew:index上,我分配并回复了这些意见。 当我发表看法时,

   [view release];

它没有发表以下意见:http://code>getCustomView:index,参考数字没有减少。

Please help me to release the view returned from getCustomVIew:index and to maintain the memory size.

当意见被删除时,文书只是增加了方案的整体规模。

最佳回答

您无需从<条码>中发布意见。 回归观点应当作为<代码>autorelease/code>加以标示。

-(UIView*) customView{
    UIView *v = [[UIView alloc] init];
    ...
    return [v autorelease];
}
问题回答

You need not to release that view in getCustomVIew:. Instead send autorelease signal before returning. After you get that view object also, you need not to release since it is already autoreleased.

你的法典似乎很严厉,如果你试图使用“观点”确保发表观点,那是不好的。

here is the exact duplicate issue you may refer: calling [myString release] does NOT decrement [myString retainCount]





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签