仅在iPad上崩溃

时间:2012-12-08 08:02:18

标签: ios ipad

我的屏幕上有一些动画。我通过使用精灵表的CAlayers为所有这些设置动画。我正在viewDidAppear方法下载所有大小为4 MB的资产。

我可以在模拟器和iPhone上显示动画。但是在iPad上接收内存警告。

在我的设备崩溃报告中,它将异常类型显示为

  

EXC_BAD_ACCESS(SIGSEGV)

我使用以下代码制作动画:

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];

摆脱这个问题的任何想法或线索?

1 个答案:

答案 0 :(得分:0)

你必须回复那个didReceiveMemory警告并释放一些资源,否则你的应用程序将被os杀死,这是你得到的这个段错误