1

我在 iPad 项目中使用粒子发射器(不使用 SpriteKit),粒子发射器是在 UIImageView 内生成的,并且由于 iOS 9,这个发射器正在使整个应用程序崩溃。实际上,整个 iPad 都在崩溃,图像冻结,除了重新启动 iPad 之外,没有什么能让 iPad 解冻。

如果我将出生率从 19.0f 降低到 6.0f,iPad 就会停止崩溃。我使用的图像是 256 × 256 大小的 png,我不确定这是否会导致它崩溃。

在 iOS 8 中一切正常。

我目前在 iPad Air 2 上使用 Xcode 7.0.1 上的 iOS 9.0.1。

+(void)smogGeneral:(UIImageView *)myView{
    [myView setNeedsDisplay];
    CALayer *rootLayer = [myView layer];
    CALayer *emitterSuperLayer = [CALayer layer];
    emitterSuperLayer.bounds = myView.bounds;
    emitterSuperLayer.sublayerTransform = CATransform3DMakeScale(1.0f, -1.0f, 1.0f);
    [rootLayer addSublayer:emitterSuperLayer];
    CGFloat midX = floorf(CGRectGetMidX(myView.bounds));
    CGFloat midY = floorf(CGRectGetMidY(myView.bounds));
    [emitterSuperLayer setPosition:CGPointMake(midX, midY)];

    CAEmitterLayer *whiteSmokeEmitter = [CAEmitterLayer layer];
    [whiteSmokeEmitter setName:@"whiteSmokeEmitter"];
    whiteSmokeEmitter.zPosition = 0.00f;
    whiteSmokeEmitter.emitterPosition = CGPointMake(300, 300);
    whiteSmokeEmitter.renderMode = kCAEmitterLayerBackToFront;
    whiteSmokeEmitter.emitterSize = CGSizeMake(10.00f, 10.0f);
    whiteSmokeEmitter.velocity = 0.05f;
    whiteSmokeEmitter.emitterMode = kCAEmitterLayerOutline;
    whiteSmokeEmitter.emitterShape = kCAEmitterLayerRectangle;

    CAEmitterCell *puffCell = [CAEmitterCell emitterCell];
    [puffCell setName:@"puffCell"];
    puffCell.contents = (__bridge id)[[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"smokeCell" ofType:@"png"]] CGImage];;
    CGColorRef colorRefPuffcell = [UIColor colorWithRed:0.99f green:0.98f blue:1.00f alpha:0.10f].CGColor;
    puffCell.color = colorRefPuffcell;
    puffCell.scale = 0.2f;
    puffCell.emissionLongitude = 1.84f;
    puffCell.emissionRange = 1.11f;
    puffCell.lifetime = 16.0f;
    puffCell.birthRate = 19.0f;
    puffCell.scaleSpeed = 0.15f;
    puffCell.velocity = 2.56f;
    puffCell.velocityRange = 9.80f;
    puffCell.xAcceleration = 9.15f;
    puffCell.yAcceleration = -0.01f;

    whiteSmokeEmitter.emitterCells = @[puffCell];
    [emitterSuperLayer addSublayer:whiteSmokeEmitter];
}
4

0 回答 0