views:

288

answers:

1

Is there any way to know which image is currently being displayed in the built in animation within a UIImageView?

I have 5 images which I need to animate through. The UIImageView provides a simple method to do this through the

animationImageView.animationImages = [NSArray ...];
animationImageView.animationDuration = 5;
animationImageView.animationRepeatCount = 0;
[animationImageView startAnimating];

But I would like to have some visual representation of which image is currently being shown. I was thinking of using the UIPageControl and having the dot highlighted represent the current image.

Is there any way to link these two, so the animation within the UIImageView can update the UIPageControl? Or do I need to write my own transitions between UIImageViews? If so can you point me in the right direction of writing a simple animation between images?

thanks

A: 

Off the top of my head, you could subclass NSArray and override objectAtIndex: to post a notification of the index whenever the the method was called. Then provide that array subclass to the animation. As the animation requests each image in sequence, the subclass would send a notification (or call a method in somewhere etc).

Not an elegant solution but it would work.

TechZen
I did some research into this and it seems that subclassing a NSArray is not recommended because it is a cluster. http://stackoverflow.com/questions/255679/app-crash-when-trying-to-access-a-subclass-method-after-the-object-was-initializeI guess the best approach is for me to write my own timer based solution which replaces the UIImage to simulate the animation
joneswah