2

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?

Gani414
  • 93
  • 2
  • 12

1 Answers1

0

you have to respond to that didReceiveMemory warning and free some resources or your app will be killed by the os which is this segfault you are getting

Daij-Djan
  • 49,552
  • 17
  • 113
  • 135