
[英]EXEC_BAD_ACCESS on applicationWillEnterForeground in iOS3 but not iOS4
[英]canSetSessionPreset:AVCaptureSessionPreset1920x1080 causes 'Bad Access' in iOS4
这是我的代码:
if( [self.captureSession canSetSessionPreset:AVCaptureSessionPreset1920x1080] == YES ) { [self.captureSession setSessionPreset:AVCaptureSessionPreset1920x1080]; self.currentPreset = GMCVideoCaptureRecordingPresetFullHD; }
在iOS4上,执行在第一行停止,并显示“错误访问”错误。 在iOS5上运行正常。
如何在此处正确检查兼容性?
AVCaptureSessionPreset1920x1080
是NSString *const
。 您只需检查其地址是否为NULL
。 像这样:
if( &AVCaptureSessionPreset1920x1080 != NULL && [self.captureSession canSetSessionPreset:AVCaptureSessionPreset1920x1080] == YES )
{
[self.captureSession setSessionPreset:AVCaptureSessionPreset1920x1080];
self.currentPreset = GMCVideoCaptureRecordingPresetFullHD;
}
那应该做你想要的。 请注意,尽管您不会在<iOS 5上设置预设,所以您可能想在其中设置else
来处理<iOS 5或无法设置1920x1080预设的情况。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.