tags:

views:

158

answers:

1

Hi, i'm having trouble about animating an Image in a UIImageView.

I've created an image view in interface builder and linked it to its iboutlet. Here is my code.

@interface Game : UIViewController <UIAccelerometerDelegate>{
    IBOutlet UIImageView *diying;       

} @property (nonatomic, retain) UIImageView *diying;

In the viewDidLoad method i've written this code

NSArray * imageArray  = [[NSArray alloc] initWithObjects:
                         [UIImage imageNamed:@"Die1.gif"],
                         [UIImage imageNamed:@"Die2.gif"],
                         [UIImage imageNamed:@"Die3.gif"],
                         [UIImage imageNamed:@"Die4.gif"],
                         nil];

diying.animationImages = imageArray;
diying.animationDuration = 1.1;
diying.contentMode = UIViewContentModeBottomLeft;
[diying startAnimating];

[super viewDidLoad];

which is a adaptation of what i've found here : http://icodeblog.com/2009/07/24/iphone-programming-tutorial-animating-a-game-sprite/

NB : those .gif files are simple images and are not animated.

I did the tutorial and it worked fine but i can't figure out why it my adaptation doesn't work !

A: 

Try loading png's instead of gif's

Also, have you allocated your UIImageView?

jAmi
Gif's are fine, when i put the gif in the other project(the tutorial) it works fine and animate itself.My UIImageView is created in interface builder, do i still have to allocate it manually ?
Fred Dpn
Yes, If you have specified its setter method; or may be not, you have to Allocate it i think. Try doing it
jAmi