2

UItableview でカスタムの再利用可能な UITableViewCell を使用したいのですが、動作しますが、インストゥルメントでテストすると、割り当て、UIViewController から出て数回再入力してもメモリが解放されないことがわかります。

私が試した3つの方法は、

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

    // method #1
    static NSString *CellIdentifier2 = @"customClassicCell";
    customClassicCell *cell = (customClassicCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier2];
    if (cell == nil){
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"customClassicCell" owner:nil options:nil];
        for(id currentObject in topLevelObjects)
        {
            if([currentObject isKindOfClass:[customClassicCell class]])
            {
                cell = (customClassicCell *)currentObject;
                break;
            }
        }
    }

    return cell;
}

また

static NSString *cellIdentifier44 = @"custom44";
- (void)viewDidLoad {
    [self.tbv registerNib:[UINib nibWithNibName:@"customClassicCell" bundle:nil] forCellReuseIdentifier:cellIdentifier44];
    [super viewDidLoad];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    // method #2
    customClassicCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier44];

    return cell;
}

また

// method3
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier44];
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellIdentifier44] ;
    }
    return cell;
}

楽器はこれを示しています(UIviewcontrollerに出入りするたびに)、3つの方法で同じ問題が発生し、メモリが正しく解放されません。 楽器の割り当て

楽器の割り当て-2

私はxcode 5.0ターゲット5.1を使用しています

ARCもストーリーボードも使用しません。誰にもアイデアがありますか?

4

0 に答える 0