我有内存泄漏导致应用程序崩溃。当我在上面评论时,我没有任何内存泄漏。
myCell.image1.image = 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;
}
图像大约为8 MB,有7张图像。当我第四次打开视图控制器时,应用程序崩溃(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。 你有什么想法吗?
答案 0 :(得分:0)
包含CustomCollectionCell的视图控制器有一个模态segue,我从未调用过下面的行。
[self dismissViewControllerAnimated:YES completion:nil];
这就是为什么我的图像没有发布。