1

我的 iPad 应用程序几乎没有内存泄漏。这是屏幕截图和代码。我每秒钟都在重新加载表格数据以显示进度。所以我怎样才能得到这个修复。

当我重新加载表时总是会发生这种情况

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   static NSString* Identifier = @"OrderCustomCell";
    UserCustomCell* cells =(UserCustomCell*) [tableView dequeueReusableCellWithIdentifier:Identifier];

    if (cells == nil)
    {
        NSArray* topLevelObjects=[[NSBundle mainBundle] loadNibNamed:@"UserCustomCell" owner:self options:nil];
        for(id currentObject in topLevelObjects)
        {
            if([currentObject isKindOfClass:[UITableViewCell class]])
            {
                cells=(UserCustomCell *)currentObject;
                break;
            }
        }
    }

        NSDictionary* dic = [tableDataArray objectAtIndex:indexPath.row];
        cells.selectionStyle = UITableViewCellEditingStyleNone;
        cells.brandName.text = [dic objectForKey:@"brandname"];
        [cells.msyncBtn setTag:indexPath.row];

        NSString* status = [dic objectForKey:@"status"];
        if ([status isEqualToString:@""])
        {
            cells.status.text = [NSString stringWithFormat:@"0%@ Completo",@"%"];
        }
        else
        {
            cells.status.text = [NSString stringWithFormat:@"%@%@ Completo",status,@"%"];
        }

        NSString* syncDate = [dic objectForKey:@"syncDate"];
        if ([syncDate isEqualToString:@""])
        {
            cells.syncDate.text = [NSString stringWithFormat:@"Não sincronizado"];
        }
        else
        {
            cells.syncDate.text = [NSString stringWithFormat:@"%@",syncDate];
        }

        NSString* totalloaded = [dic objectForKey:@"totalloaded"];
        if ([totalloaded isEqualToString:@""])
        {
            cells.totalLoaded.text = [NSString stringWithFormat:@""];
        }
        else
        {
            cells.totalLoaded.text = [NSString stringWithFormat:@"%@",totalloaded];
        }
    return cells;
}

请检查此图像

截图 1

4

1 回答 1

0

尝试这个

if (cells == nil)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];
    NSArray* topLevelObjects=[[NSBundle mainBundle] loadNibNamed:@"UserCustomCell" owner:self options:nil];
    for(id currentObject in topLevelObjects)
    {
        if([currentObject isKindOfClass:[UITableViewCell class]])
        {
            cells=(UserCustomCell *)currentObject;
            break;
        }
    }
[pool drain];
}
于 2013-02-18T08:24:43.980 回答