【问题标题】:Using an animated UIImageView as an iPhone camera overlay使用动画 UIImageView 作为 iPhone 相机覆盖
【发布时间】:2010-02-26 23:53:32
【问题描述】:

正如标题所说,在 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 的限制吗?

【问题讨论】:

    标签: iphone-sdk-3.0 animation uiimageview camera


    【解决方案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]; 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多