【发布时间】:2012-01-01 08:51:12
【问题描述】:
我有以下代码将标签添加到 UITableView 的页脚中,以便我可以格式化文本(白色等)
它工作正常,但它给我一个“headerLabel”的泄漏警告,当它在“return”的行上分析它时
// create the parent view that will hold header Label
UIView* customView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 15.0, 300.0, 44.0)];
// create the button object
UILabel * headerLabel = [[UILabel alloc] initWithFrame:CGRectZero];
headerLabel.backgroundColor = [UIColor clearColor];
headerLabel.opaque = NO;
headerLabel.textColor = [UIColor whiteColor];
headerLabel.highlightedTextColor = [UIColor whiteColor];
headerLabel.font = [UIFont systemFontOfSize:14];
headerLabel.textAlignment=UITextAlignmentCenter;
headerLabel.frame = CGRectMake(10.0, 0.0, 300.0, 75.0);
headerLabel.numberOfLines=4;
if (section==0) {
headerLabel.text = @"If turned off, the last used settings will be used on the next session\n\n"; // i.e. array element
}
[customView addSubview:headerLabel];
//[headerLabel release];
return customView;
// [customView release];
我试着把版本放在这里和那里,但它总是一样的。
非常感谢你们的反馈。
【问题讨论】:
-
不,我不是。在 Xcode 4.2 上工作,但使用的是旧项目,所以我没有“现代化”它
-
这个在SO上已经讲了很多次了,我觉得最好不要重复,搜索Cocoa内存管理。
-
嗯,这是我第一次有潜在的内存泄漏,我检查了所有关于内存管理的文档,但我只是大脑受阻。很抱歉。
标签: iphone cocoa-touch debugging memory-leaks memory-management