I'm trying to load 4 UIImageView to run different animations. Each animation is composed of 164 png of 6 KB of size each one.
I've tested in instruments and when runs in simulator works fine and the size in memory is less than 5,5 MB.
But when runs in the iPad the app just crashes without log message or memory warnings. I've tested in instruments and the size in memory is less than 5 MB before crash.
Here the code.
-(void)startAnimations
{
OTAnimationProvider *ani = [[OTAnimationProvider alloc] init];
int a;
for (a=0;a<[teams CountY];a++)
{
UIImageView *animationTeam = [[UIImageView alloc] initWithFrame:CGRectMake(10, 300 + (40 * a), 1004, 300)];
int idTeam = [[teams getValueByName:@"IdTeam" posY:a] intValue];
[animationTeam setAnimationImages:[ani animationWithName:[NSString stringWithFormat: @"OTScoreBoardLeague_%d_%d_",idTeam,a+1] frameCount:164 step:2]];
[animationTeam setAnimationDuration:animationPlayersTime];
[animationTeam setAnimationRepeatCount:1];
[animationTeam startAnimating];
[self.view addSubview:animationTeam];
[animationTeam release];
}
[ani release];
}
OTAnimationProvider object is only an object with a method that returns the images array of the animation.
Any idea of what I'm doing wrong :(
Thanks.
UPDATE---
I've tried to use an animation Atlas with CALayer object. But I'm still obtaining the same results.
In device the app crashes without any error message in debug.
This is the code:
CALayer *layer = [CALayer layer];
CGImageRef img = [[UIImage imageNamed:@"OTScoreBoardLeagueAtlasTeam_1_1.png"]CGImage];
layer.contents = (id)img;
CGSize size = CGSizeMake( 1004, 300 ); // size in pixels of one frame
CGSize normalizedSize = CGSizeMake( size.width/CGImageGetWidth(img), size.height/CGImageGetHeight(img) );
layer.bounds = CGRectMake( 0, 0, size.width, size.height );
layer.contentsRect = CGRectMake( 10, 300 + (20 * a), normalizedSize.width, normalizedSize.height );
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"sampleIndex"];
anim.fromValue = [NSNumber numberWithInt:1]; // initial frame
anim.toValue = [NSNumber numberWithInt:165]; // last frame + 1
anim.duration = 8.0f; // from the first frame to the 6th one in 1 second
anim.repeatCount = 0; // just keep repeating it
anim.autoreverses = NO; // do 1, 2, 3, 4, 5, 4, 3, 2
[layer addAnimation:anim forKey:nil]; // start
[self.view.layer addSublayer:layer];
Any ideas?
Thanks.