2010-02-26 48 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];