繁体   English   中英

canSetSessionPreset:AVCaptureSessionPreset1920x1080在iOS4中导致“访问错误”

[英]canSetSessionPreset:AVCaptureSessionPreset1920x1080 causes 'Bad Access' in iOS4

这是我的代码:

if( [self.captureSession canSetSessionPreset:AVCaptureSessionPreset1920x1080] == YES )
    {
    [self.captureSession setSessionPreset:AVCaptureSessionPreset1920x1080];
    self.currentPreset = GMCVideoCaptureRecordingPresetFullHD;
    }

在iOS4上,执行在第一行停止,并显示“错误访问”错误。 在iOS5上运行正常。

如何在此处正确检查兼容性?

AVCaptureSessionPreset1920x1080NSString *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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM