I have some animations in my screen. I am animating all of them through CAlayers using sprite sheets. I am downloading all the assets which sizes to 4 MB in viewDidAppear
method.
I am able to show the animations on both simulators and on iPhone. But receiving memory warnings on iPad.
In my device crash reports it is showing exception type as
EXC_BAD_ACCESS(SIGSEGV)
I am animating using the following code:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *getImagePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.png", imageNameStr]]; UIImage *img = [UIImage imageWithContentsOfFile:getImagePath];
CGImageRef richterImgPl1 = [UIImage imageWithContentsOfFile:getImagePath].CGImage;
NSArray *arrayWithSprites = [img spritesWithSpriteSheetImage:img
spriteSize:CGSizeMake(230,350)];
CGSize fixedSize = CGSizeMake(230, 350);
MCSpriteLayer *richterPl1 = [MCSpriteLayer layerWithImage:richterImgPl1 sampleSize:fixedSize] ;
richterPl1.frame = imgView.frame;
richterPl1.position = imgView.layer.position;
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"sampleIndex"];
anim.fromValue = [NSNumber numberWithInt:1];
anim.toValue = [NSNumber numberWithInt:arrayWithSprites.count];
anim.duration = sleepTime;//[imgView.animationImages count] * 0.0500;
anim.repeatCount = 1;
[richterPl1 addAnimation:anim forKey:nil];
[self.view.layer addSublayer:richterPl1];
Any ideas or clues to get rid of this issue?