アプリをクラッシュさせるメモリ リークがあります。上記の行にコメントすると、メモリリークはありません。
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を使用しています。あなたはなにか考えはありますか?