0

フォルダーからのみ (Web サーバーからではなく) 画像を読み込むアプリを開発しています。

かなり問題なく動作していますが、UITableView によるメモリ消費が心配です。

UITableView をスクロールするたびに、メモリが割り当てられ、割り当てが解除されることはありません
すべてのオブジェクトで release を使用しています。

以下の私のコードを見てください。

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"OtherThingsName"];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"OtherThingsName"];
    }

    if ([cell viewWithTag:123]!=nil) {
        NSLog(@"Removed");
        [[cell viewWithTag:123] removeFromSuperview];
        [[cell viewWithTag:1231] removeFromSuperview];
        [[cell viewWithTag:1232] removeFromSuperview];
    }

    UIView *viewInTableCell=nil;
    UILabel *lblTitleInCell=nil;
    UIImageView *imageInCell=nil;

    viewInTableCell = [[UIView alloc] initWithFrame:cell.bounds];
    lblTitleInCell = [[UILabel alloc] initWithFrame:CGRectMake(120, (cell.bounds.size.height/2), 190, 30)];
    imageInCell = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 100, 80)];

    [lblTitleInCell setText:[self.arrayOfOtherThings objectAtIndex:indexPath.row]];
    [imageInCell setImage:[UIImage imageNamed:[self.arrayOfImages objectAtIndex:indexPath.row]]];

    [viewInTableCell setTag:123];
    [lblTitleInCell setTag:1231];
    [imageInCell setTag:1232];

    [viewInTableCell addSubview:lblTitleInCell];
    [viewInTableCell addSubview:imageInCell];

    [cell addSubview:viewInTableCell];

    //    cell.textLabel.text = [self.arrayOfOtherThings objectAtIndex:indexPath.row];

    lblTitleInCell = nil;
    imageInCell = nil;
    viewInTableCell = nil;

    [lblTitleInCell release];
    [imageInCell release];
    [viewInTableCell release];

    return cell;
}
4

0 に答える 0