2017-08-08 77 views
3
@objc func launchCoreML() { 
    let settings = AVCapturePhotoSettings() 
    let previewPixelType = settings.availablePreviewPhotoPixelFormatTypes.first 
    let previewFormat = [ 
     kCVPixelBufferPixelFormatTypeKey as String: previewPixelType, 
     kCVPixelBufferWidthKey as String: 160, 
     kCVPixelBufferHeightKey as String: 160 
    ] as [String : Any] 

    settings.previewPhotoFormat = previewFormat 
    cameraOutput.capturePhoto(with: settings, delegate: self) 
} 

我有一個錯誤說:類型的價值型 'AVCapturePhotoSettings' 沒有成員「availablePreviewPhotoPixelFormatTypes

值 'AVCapturePhotoSettings' 沒有成員 'availablePreviewPhotoPixelFormat'。

我使用的Xcode 9

回答

6

的beta版測試版4這讓重命名爲__availablePreviewPhotoPixelFormat。我還沒有看過測試版5。

+0

在測試版5中還有'__availablePreviewPhotoPixelFormatTypes'。 – OOPer

+0

非常感謝! – LogicFlow

+0

我正在努力在beta 5中找到同樣的東西。 – Allamaprabhu

0
 var photoSettings: AVCapturePhotoSettings 
     if #available(iOS 11.0, *) { 
      photoSettings = AVCapturePhotoSettings.init(format: [AVVideoCodecKey: AVVideoCodecType.jpeg]) 
     } else { 
      // Fallback on earlier versions 
      photoSettings = AVCapturePhotoSettings() 
      if photoSettings.__availablePreviewPhotoPixelFormatTypes.count > 0 { 
       photoSettings.previewPhotoFormat = [kCVPixelBufferPixelFormatTypeKey as String : photoSettings.__availablePreviewPhotoPixelFormatTypes.first!] 
      } 
     } 
相關問題