Iphone I';m使用图形图像上下文为UIView动画数组预处理图片。如果不再需要此阵列,如何释放内存?
我正在使用图形图像上下文为Iphone I';m使用图形图像上下文为UIView动画数组预处理图片。如果不再需要此阵列,如何释放内存?,iphone,xcode,memory-management,uiviewanimation,Iphone,Xcode,Memory Management,Uiviewanimation,我正在使用图形图像上下文为UIView动画数组预处理图片 如果我不再需要此阵列和所有这些图像,如何释放内存?\u picturearlay=nil足够吗 - (NSMutableArray *)generateCachedImageArrayWithFilename:(NSString *)filename extension:(NSString *)extension andImageCount:(int)count { _imagesArray = [[NSMutableArray
UIView
动画数组预处理图片
如果我不再需要此阵列和所有这些图像,如何释放内存?\u picturearlay=nil
足够吗
- (NSMutableArray *)generateCachedImageArrayWithFilename:(NSString *)filename extension:(NSString *)extension andImageCount:(int)count
{
_imagesArray = [[NSMutableArray alloc] init];
_fileExtension = extension;
_imageName = filename;
_imageCount = count;
for (int i = 0; i < count; i++)
{
NSString *tempImageNames = [NSString stringWithFormat:@"%@%i", filename, i];
NSString *imagePath = [[NSBundle mainBundle] pathForResource:tempImageNames ofType:extension];
UIImage *frameImage = [UIImage imageWithContentsOfFile:imagePath];
UIGraphicsBeginImageContext(frameImage.size);
CGRect rect = CGRectMake(0, 0, frameImage.size.width, frameImage.size.height);
[frameImage drawInRect:rect];
UIImage *renderedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[_imagesArray addObject:renderedImage];
if (_isDoublingFrames)
{
[_imagesArray addObject:renderedImage];
}
else if (_isTripplingFrames)
{
[_imagesArray addObject:renderedImage];
[_imagesArray addObject:renderedImage];
}
NSLog(@"filename = %@", filename);
}
return _imagesArray;
}
-(NSMutableArray*)generateCachedImageArrayWithFilename:(NSString*)文件扩展名:(NSString*)扩展名和图像计数:(int)计数
{
_imagesArray=[[NSMutableArray alloc]init];
_fileExtension=扩展;
_imageName=文件名;
_imageCount=计数;
for(int i=0;i
只需从阵列中删除要释放的图像即可
或者在数组上调用removeAllObjects
,将其清除
因为阵列是唯一保存图像的阵列(假设您现在不显示它)
- 可以使用
或removeObject
removeAllObjects
- 释放阵列可以通过以下方式完成:
- (非arc)调用
或release
- (使用arc)将其设置为nil(但这不可靠),因此我将其称为'removeAllObjects'
- (非arc)调用
removeAllObjects
,将其清除
因为阵列是唯一保存图像的阵列(假设您现在不显示它)
- 可以使用
或removeObject
removeAllObjects
- 释放阵列可以通过以下方式完成:
- (非arc)调用
或release
- (使用arc)将其设置为nil(但这不可靠),因此我将其称为'removeAllObjects'
- (非arc)调用