我一直在设备(iOS 5)上测试应用程序,同时使用仪器,我发现了几个内存泄漏。
这是我从Instruments被重定向到的代码的一部分(参见箭头中的确切行):
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CeldaUltimasFotosViewCell *cell =
(CeldaUltimasFotosViewCell *) [self.tableView
dequeueReusableCellWithIdentifier:@"CeldaUltimasFotosViewCell"];
if (cell == nil) {
- - - - > NSArray *topLevelObjects =
[[NSBundle mainBundle]
loadNibNamed:@"CeldaUltimasFotosViewCell"
owner:nil options:nil];
cell = [topLevelObjects objectAtIndex:0];
}
// Configure the cell...
[[cell titulo] setFont:fuente_titulo];
...
return cell;
}如您所见,我有一个从NIB文件加载的自定义单元格。单元格有三个文件(customCell.m、customCell.h、customCell.xib)。问题是,我不知道是否必须在单元控制器中释放一些东西(现在是空的,没有方法),因为这是带ARC的iOS 5。
发布于 2012-02-13 16:26:13
发布于 2012-02-12 19:52:11
看一下Table View编程,以及如何从NIB (XIB)文件加载单元格。
第一件奇怪的事情是你将单元格存储在一个局部变量中。您应该将自定义单元格连接到类中的属性,并且您在代码中所调用的全部内容是:
[[NSBundle mainBundle] loadNibNamed:@"CeldaUltimasFotosViewCell" owner:self options:nil];遵循从Nib文件加载自定义表格-视图单元格的代码,你不会出错的。
https://stackoverflow.com/questions/9248467
复制相似问题