Tableviecells没有被解除分配.....内存管理问题

时间:2009-11-19 06:27:34

标签: iphone uitableview memory-management core-data

我正在开发一个应用程序,其中定制了uitableview的uitableviewcells,其中包含textfied(包含managedobject / core数据),label(包含managedobject),按钮等所有都是自定义的。我正在使用sqlite动态创建uitableview。 / p>

My tablview UI http://grab.by/FiJ

同样,uitableview视图包含超过15个单元格。细胞显示完美。 但我面临着细胞占用的内存问题。

如果i tab on next / prev,同一个表视图将使用核心数据重新加载新单元格(也是新数据)。但是在这种情况下,应该解除先前的细胞(细胞的记忆)。但是在导航到其他视图时(使用上一个/下一个按钮),内存会不断增加和增加。

奇怪的是, 当我连续滚动tablview时,会创建和创建单元格,并且内存会逐渐增加。

感谢。

1 个答案:

答案 0 :(得分:1)

我认为

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

工作不正确。

检查您的单元格是否具有在代码中使用的相同单元格标识符(您可以在IB中指定它):

static NSString *cellIdentifier = @"myIdentifier";
MyCell* cell = (MyCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
         if (cell == nil) {
            cell = [[[MyCell alloc] init] autorelease];
         }
cell.text = @"Yahoo!";
...

我认为这是你的问题。