每次我更改UIImageView的映像时,都会将2-3 MBs添加到运行内存中,如Xcode中的左内存侧栏所示。下面是使用Xcode 5中的一个UIImageView循环几个映像的代码:
- (void)PlayThoseImages{
if(CurrentImage < TotalNumOfImgaes){
CurrentImage++ ;
ImageName = @"Image .png" ;
NameString = [NSString stringWithFormat:@" %i",CurrentImageString] ;
ImageName = [ImageName stringByReplacingOccurrencesOfString:@" " withString: CurrentImageString] ;
BackgroundImage.image = [UIImage imageNamed:ImageName] ;
[self performSelector:@selector(PlayThoseImages) withObject:nil afterDelay:DelayInteger];
}
else{
ImageName = nil ;
CurrentImageString = nil ;
}
}字符串、ImageName和CurrentImageString是在头中声明的全局NSStrings,整数也是。
延迟循环按预期运行,更改所显示图像的名称的字符串工作得很好,但是为什么每次它投影一个新图像(循环一次)时,2-3 MBs的内存是否会增加?我正在使用ARC。
发布于 2014-07-31 14:08:48
https://stackoverflow.com/questions/25060902
复制相似问题