2016-12-15 49 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];