【发布时间】:2011-07-20 10:26:57
【问题描述】:
我正在使用自定义单元格来填充我的一张表格。但是每当我向上和向下滚动时,我都可以看到发生了一些泄漏,这些泄漏指向 UIKit Lib。不知道为什么?作为参考,我附上了泄漏仪器的泄漏屏幕截图。
感谢您的帮助!!
TableView cellForRowIndex:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *cellIdentifier = [NSString stringWithFormat:@"EditingCell_%d_%d",indexPath.section,indexPath.row];
EditingTableViewCell *cell = (EditingTableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
[self.appCellNib instantiateWithOwner:self options:nil];
cell = editingTableViewCell;
self.editingTableViewCell = nil;
}
自定义单元格:
@implementation EditingTableViewCell
@synthesize label,textField,commentField,dateLabel;
#pragma mark -
#pragma mark == Initialization ==
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code.
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
}
#pragma mark -
#pragma mark == Memory Management ==
- (void)dealloc {
[label release];
[textField release];
[commentField release];
[dateLabel release];
[super dealloc];
}
【问题讨论】:
-
最有趣的部分一定在
tableView:cellForRowAtIndexPath:方法中 -
@Vince:我已经交叉检查了好几次,但一切都很好。
-
请将您的表格单元创建代码放在这里
-
@manoj - 所以,很抱歉,不知道为什么会出现泄漏
-
请在此处提供有关您的 tableView:cellForRowAtIndexPath 代码的更多详细信息。所以,可以为您提供更多帮助。
标签: iphone memory memory-leaks