【发布时间】:2014-03-16 08:41:00
【问题描述】:
我的图片代码是
-(IBAction)start:(id)sender
{
animation.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"Paddle 1.png"],
[UIImage imageNamed:@"Paddle 2.png"],
[UIImage imageNamed:@"Paddle 3.png"],
[UIImage imageNamed:@"Paddle 4.png"],
nil];
[animation setAnimationRepeatCount:0];
animation.animationDuration = 2.5;
[animation startAnimating];
}
这缓存了太多内存,我在上一个问题中被告知要交换我的代码以使用
[UIImage imageWithContentsOfFile: GetImgWithoutCaching(@"Paddle 1.jpg")]
和
UIImage* GetImgWithoutCaching(NSString* imgName)
{
NSString *imagePath = [[NSBundle mainBundle] pathForResource:imgName ofType:nil];
return [UIImage imageWithContentsOfFile:imagePath];
}
编写代码的正确方法是什么?我是否将该代码按原样放在我的 .m 中?
【问题讨论】: