0

アプリをクラッシュさせるメモリ リークがあります。上記の行にコメントすると、メモリリークはありません。

myCell.image1.image = 画像;

myCell はカスタムUICollectionViewCellであり、次のように作成されます。

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
             cellForItemAtIndexPath:(NSIndexPath *)indexPath
{

    CustomCollectionCell *myCell = [collectionView dequeueReusableCellWithReuseIdentifier:@"project" forIndexPath:indexPath]; 

    NSData *imageData = [NSData dataWithContentsOfFile:_images[row] options:0 error:NULL];
    UIImage *image = [UIImage imageWithData:imageData];
    myCell.image1.image = image;
    return myCell;
} 

画像は約8MBで7枚あります。View Controller を 4 回目に開くと、アプリがクラッシュします (8x7x4 > 200 MB) ;)

CustomCollectionCell.h

#import <UIKit/UIKit.h>
#import "CellButton.h"

@interface CustomCollectionCell : UICollectionViewCell

@property (strong, nonatomic) IBOutlet UILabel *titlePro;
@property (strong, nonatomic) IBOutlet UILabel *datePro;
@property (strong, nonatomic) IBOutlet UIImageView *image1;
@property (strong, nonatomic) IBOutlet CellButton * button;

@end

CustomCollectionCell.m

#import "CustomCollectionCell.h"
#import "UIView+Themes.h"

@implementation CustomCollectionCell

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
    // Initialization code
    }
    return self;
}


@end

プロファイリングすると、Live Bytes が 200 MB を超え、アプリがエラーなしでクラッシュします。私がコメントするときmyCell.image1.image = image;。アプリはクラッシュしません。

ARCを使用しています。あなたはなにか考えはありますか?

4

1 に答える 1

0

CustomCollectionCell を含むビュー コントローラーにはモーダル セグエがあり、以下の行を呼び出すことはありませんでした。

[self dismissViewControllerAnimated:YES completion:nil];

そのため、私の画像は公開されませんでした。

于 2013-10-16T21:13:35.290 に答える