Reputation: 776
I have the following code inside my app, but it doesn't animate the UIImageView, can anyone tell me why?
UITableViewCell* cell = [selectedTable cellForRowAtIndexPath:selectedPath];
NSArray* myImageArray = [NSArray arrayWithObjects:
[UIImage imageNamed:[[NSBundle mainBundle] pathForResource:@"boxBeingChecked117x11" ofType:@"png"]],
[UIImage imageNamed:[[NSBundle mainBundle] pathForResource:@"boxBeingChecked217x11" ofType:@"png"]],
[UIImage imageNamed:[[NSBundle mainBundle] pathForResource:@"boxBeingChecked317x11" ofType:@"png"]],
[UIImage imageNamed:[[NSBundle mainBundle] pathForResource:@"boxBeingChecked417x11" ofType:@"png"]],
[UIImage imageNamed:[[NSBundle mainBundle] pathForResource:@"boxBeingChecked517x11" ofType:@"png"]],
[UIImage imageNamed:[[NSBundle mainBundle] pathForResource:@"boxBeingChecked617x11" ofType:@"png"]],
nil];
cell.imageView.animationImages = myImageArray;
cell.imageView.animationDuration = 4.20;
cell.imageView.animationRepeatCount = 1;
[cell.imageView startAnimating];
[NSTimer scheduledTimerWithTimeInterval:4.0
target:self
selector:@selector(methodToInvokeAfterAnimationIsDone)
userInfo:nil
repeats:NO];
Upvotes: 1
Views: 566
Reputation: 415
Make sure that the imageView
's highlighted
property is set to NO
, otherwise the code you have above will not work. If you want to animate highlighted images, use highlightedAnimationImages
.
Upvotes: 0
Reputation: 8564
You should use this:
NSArray* myImageArray = [NSArray arrayWithObjects:
[UIImage imageNamed:@"boxBeingChecked117x11.png"]],
[UIImage imageNamed:@"boxBeingChecked217x11.png"]],
[UIImage imageNamed:@"boxBeingChecked317x11.png"]],
[UIImage imageNamed:@"boxBeingChecked417x11.png"]],
[UIImage imageNamed:@"boxBeingChecked517x11.png"]],
[UIImage imageNamed:@"boxBeingChecked617x11.png"]],
nil];
You need to give name of the file, not the path, in imageNamed
: method.
Upvotes: 1