2016-12-15 134 views
1

我的应用程序中有使用的相机,然后压缩图像JPEG,与iOS版本< 10,我用AVCaptureStillImageOutput但IOS版本> = 10我用AVCapturePhotoOutput error.I已设置代码:`ios 10中的AVCapturePhotoSettings错误?

self.photoOutput = [[AVCapturePhotoOutput alloc] init]; 
     AVCapturePhotoSettings *photoSettings = 
      [AVCapturePhotoSettings photoSettingsWithFormat:@{AVVideoCodecKey : AVVideoCodecJPEG}]; 

    [self.photoOutput capturePhotoWithSettings:photoSettings delegate:self]; 
    [self.session addOutput:self.photoOutput];` 

我有问题时,运行应用程序,错误应用程序崩溃:

[AVCapturePhotoOutput capturePhotoWithSettings:delegate:] No active and enabled video connection 

有人知道如何使用它?谢谢。

回答

0

您需要调用[self.session addOutput:];[self.photoOutput capturePhotoWithSettings:delegate:];

尝试:

self.photoOutput = [[AVCapturePhotoOutput alloc] init]; 
     AVCapturePhotoSettings *photoSettings = 
      [AVCapturePhotoSettings photoSettingsWithFormat:@{AVVideoCodecKey : AVVideoCodecJPEG}]; 
[self.photoOutput capturePhotoWithSettings:photoSettings delegate:self]; 
[self.session addOutput:self.photoOutput];