presentRenderbuffer EXC_BAD_ACCESS崩溃

时间:2015-10-06 08:02:51

标签: ios opengl-es core-motion

我使用CoreMotion获得如下的摇动加速度值:

-(void)startAccelerometer {
    [self.motionManager startAccelerometerUpdatesToQueue:[[NSOperationQueue alloc]init]
                                             withHandler:^(CMAccelerometerData *accelerometerData, NSError *error) {
                                                 [self outputAccelertionData:accelerometerData.acceleration];
                                                 if (error) {
                                                     NSLog(@"motion error:%@",error);
                                                 }
                                             }];
}

-(void)outputAccelertionData:(CMAcceleration)acceleration {
    double accelerameter =sqrt( pow( acceleration.x , 2 ) + pow( acceleration.y , 2 )
                               + pow( acceleration.z , 2) );
    if (accelerameter>2.3f) {
        dispatch_async(dispatch_get_main_queue(), ^{
            [[NSNotificationCenter defaultCenter] postNotificationName:@"shaked" object:[NSValue value:&acceleration withObjCType:@encode(CMAcceleration)]];
        });
    }
}

在我的另一个glView控制器中,观察shaked通知并执行render内容,但它经常在[self.glContext presentRenderbuffer:GL_RENDERBUFFER];行崩溃,请参阅堆栈跟踪:

enter image description here

有什么想法吗?

0 个答案:

没有答案