就像标题所说,在iPhone SDK中,我想创建一个动画UIImageView并将其用作相机叠加层。然而,什么也没出现。我一直在使用相同的设置将静态图像显示为叠加层,但在尝试使用以下代码时,不会出现叠加层:
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的限制吗?
答案 0 :(得分:1)
我正在尝试做同样的事情。当它只是一个叠加图像时它会工作,但是一旦我尝试使用图像数组进行动画处理,就没有任何显示。
我正在使用imageWithContentsOfFile加载pngs。它不会将图像加载到图像文件中。它需要实际的路径。 试试这样的事情:
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];