Using an animated UIImageView as an iPhone camera overlay

Like the title says, in the iPhone SDK, I want to create an animated UIImageView and use it as a camera overlay. However, nothing appears. I've been using the same setup to display a static image as an overlay, but when trying to use the following code, no overlay appears:

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"],
        imageView.animationDuration = 1.0;
        imageView.animationRepeatCount = 0;
        [imageView startAnimating];

I know the above code works when the imageView is not used as an overlay. Any thoughts? Is this just a limitation of the current SDK?


I am trying to do the same thing. It will work when its just an overlay image, but once I try to animate with an array of images, nothing shows.

I was loading the pngs all wrong with imageWithContentsOfFile. It wont load the image it its just the image file. It needs the actual path. Try this something like this:

   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]; 

Need Your Help

AS3 qestion about removing objects and memory/garbage collection

actionscript-3 memory memory-management memory-leaks garbage-collection

I have a routine that repeatedly builds and rebuilds a big dynamic movieclip full of buttons called "bigList". When it rebuilds, it first attempts to trash bigList so that it doesn't repeatedly add

TortoiseHg and multiple tags

tags tortoisehg

Is it possible to assign multiple tags to commits using TortoiseHg? Currently, I can set only one tag to a particular commit, Looks like TortoiseHg doesn't allow more than one tag. So, is it possib...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.