2011-04-27 107 views
0

我在我所採取的ImageView作爲背景,並在ImageView的我使用89個圖像作出animation.Here是我的代碼做動畫Ipad的動畫圖像崩潰問題

-(void)viewWillAppear:(BOOL)animated 
{ 

NSString *cachesDirectoryPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];  
NSLog(@"cachesDirectoryPath: %@", cachesDirectoryPath); 
    CPIAppDelegate *obj=(CPIAppDelegate *)[[UIApplication sharedApplication]delegate]; 
    arrayOfImages=[[NSMutableArray alloc]init]; 

    viewMenu.hidden = obj.buttonStatus; 
    for (int i=0; i<IMAGE_ANIMATION_COUNT; i++) { 
// [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/streamvideo351_frame%d.jpg",cachesDirectoryPath,i]]; 
     [arrayOfImages addObject:[UIImage imageNamed:[NSString stringWithFormat:@"streamvideo351_frame%d.jpg",i]]]; 

    } 

    BackGrdImage.animationImages=arrayOfImages; 
    BackGrdImage.animationDuration =5.0; 
    BackGrdImage.animationRepeatCount =3; 
    [BackGrdImage startAnimating]; 
    [arrayOfImages removeAllObjects]; 

} 

和應用在dealloc方法中我使用

[imageAnimations release]; 
[BackGrdImage removeFromSuperview]; 
[BackGrdImage release]; 

它正常工作模擬器上的崩潰,但在Ipad.What在ipad上實際發生的是有時它會閃爍,一段時間一次disappear.So請幫我出這個friends.I我也在-(void)viewWillDisappear上發佈了這個數組e朋友幫助我與它任何幫助或建議將不勝感激。

+0

可能不是問題,但請確保您在viewWillAppear:方法的某個時刻調用[super viewWillAppear:animated]。 – Sam 2011-04-27 06:31:11

回答

0

您的應用程序崩潰,因爲BackGrdImage你釋放後陣動畫只有一次

[arrayOfImages removeAllObjects]

BackGrdImage.animationRepeatCount = 3;

由於這個原因您的圖片第二次進行了動畫製作,但BackGrdImage沒有獲得動畫的arrayOfImages,因此您的應用程序會崩潰。

有一種方法,當你的圖像動畫三次意味着在1.5秒內,然後你必須調用一種方法釋放arrayOfImages。 上述過程肯定會奏效。

0

您可能正在收到內存警告。因爲我不認爲該設備將支持89圖像/圖像瀏覽的圖像數組。嘗試在設備上調試您的應用。