2010-02-26 45 views
0

就像標題所說,在iPhone SDK中,我想創建一個動畫UIImageView並將其用作相機覆蓋。但是,沒有出現。我一直在使用相同的設置來顯示靜態圖像的疊加,而是嘗試使用下面的代碼的時候,沒有出現重疊:使用動畫UIImageView作爲iPhone相機覆蓋

imageView.animationImages = [NSArray arrayWithObjects: 
            [UIImage imageNamed:@"cameraScreenOverlay1.png"], 
            [UIImage imageNamed:@"cameraScreenOverlay2.png"], 
            [UIImage imageNamed:@"cameraScreenOverlay3.png"], 
            [UIImage imageNamed:@"cameraScreenOverlay4.png"], 
            [UIImage imageNamed:@"cameraScreenOverlay4.png"], 
            [UIImage imageNamed:@"cameraScreenOverlay4.png"], 
            [UIImage imageNamed:@"cameraScreenOverlay3.png"], 
            [UIImage imageNamed:@"cameraScreenOverlay2.png"], 
            [UIImage imageNamed:@"cameraScreenOverlay1.png"], 
            nil]; 
     imageView.animationDuration = 1.0; 
     imageView.animationRepeatCount = 0; 
     [imageView startAnimating]; 

我知道上面的代碼工作時ImageView的不作爲覆蓋。有什麼想法嗎?這僅僅是當前SDK的限制嗎?

回答

1

我正在嘗試做同樣的事情。當它只是一個覆蓋圖像時它會工作,但是一旦我嘗試使用一組圖像進行動畫處理時,什麼也不會顯示。

我當時正在用imageWithContentsOfFile加載所有錯誤的png。它不會將圖像加載到圖像文件中。它需要實際的路徑。 試試這件事:

NSArray *animationImages = [NSArray arrayWithObjects: 
           [UIImage imageWithContentsOfFile:[[ NSBundle mainBundle] pathForResource:@"back1" ofType:@"png"]], 
           [UIImage imageWithContentsOfFile:[[ NSBundle mainBundle] pathForResource:@"back2" ofType:@"png"]], 
           [UIImage imageWithContentsOfFile:[[ NSBundle mainBundle] pathForResource:@"back3" ofType:@"png"]], 
           [UIImage imageWithContentsOfFile:[[ NSBundle mainBundle] pathForResource:@"back4" ofType:@"png"]], 
           [UIImage imageWithContentsOfFile:[[ NSBundle mainBundle] pathForResource:@"back5" ofType:@"png"]], 
           [UIImage imageWithContentsOfFile:[[ NSBundle mainBundle] pathForResource:@"back6" ofType:@"png"]], 
           [UIImage imageWithContentsOfFile:[[ NSBundle mainBundle] pathForResource:@"back7" ofType:@"png"]],nil]; 


    imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,320,480)]; 
    imageview.animationImages = [animationImages retain] ; 
    imageview.animationRepeatCount = 0; 
    imageview.animationDuration= 1; 

    [overlay.view addSubview:imageview]; 

    [moviePlayerWindow addSubview:overlay.view];