由於每次動畫之後都會建立內存,導致我的應用程序崩潰。iphone動畫之後的空閒內存
這裏是我的示例代碼:
-(IBAction) shoot: (id)delegate{
[gun setImage:[UIImage imageNamed:@"animation_machin_guns_320x480_7.png"]];
UIImage *frame1 = [UIImage imageNamed:@"animation_machin_guns_320x480_1.png"];
UIImage *frame2 = [UIImage imageNamed:@"animation_machin_guns_320x480_2.png"];
UIImage *frame3 = [UIImage imageNamed:@"animation_machin_guns_320x480_3.png"];
UIImage *frame4 = [UIImage imageNamed:@"animation_machin_guns_320x480_4.png"];
UIImage *frame5 = [UIImage imageNamed:@"animation_machin_guns_320x480_5.png"];
UIImage *frame6 = [UIImage imageNamed:@"animation_machin_guns_320x480_6.png"];
UIImage *frame7 = [UIImage imageNamed:@"animation_machin_guns_320x480_7.png"];
gun.animationImages = [[NSArray alloc] initWithObjects:frame1, frame2, frame3, frame4, frame5, frame6, frame7,nil];
gun.animationDuration = 1;
gun.animationRepeatCount = 1;
[gun startAnimating];
[frame1 release];
[frame2 release];
[frame3 release];
[frame4 release];
[frame5 release];
[frame6 release];
[frame7 release];}
釋放框架似乎並沒有這樣做的魔力。 我試過使用這http://kosmaczewski.net/projects/iphone-image-cache/進行圖像緩存,但我想我不知道如何正確使用它,因爲內存構建比使用imageNamed更快。
我需要所有的屏幕動畫,我已經儘量減少圖像的文件大小。 – Subject78 2010-09-20 13:28:52