将Xcode 8升级到XCode 9后出现AvCapture错误

问题描述 投票:2回答:1

我正在研究另一个开发人员的代码,它是一个相机应用程序。我已经完成了它并且在升级到xCode 9之前工作正常。下面是代码片段

@objc protocol AVCapturePhotoOutputType {
@available(iOS 10.0, *)
var isLensStabilizationDuringBracketedCaptureSupported: Bool {get}
@available(iOS 10.0, *)
var availableRawPhotoPixelFormatTypes: [Int] {get}
@available(iOS 10.0, *)
var isHighResolutionCaptureEnabled: Bool {get 
@objc(setHighResolutionCaptureEnabled:) set}
@available(iOS 10.0, *)
var supportedFlashModes: [Int] {get}
@available(iOS 10.0, *)
func connection(withMediaType mediaType: String!) -> AVCaptureConnection!
@available(iOS 10.0, *)
@objc(capturePhotoWithSettings:delegate:)
func capturePhoto(with settings: AVCapturePhotoSettings, delegate: 
AVCapturePhotoCaptureDelegate)}

@available(iOS 10.0, *)
extension AVCapturePhotoOutput:AVCapturePhotoOutputType {}

现在我在线路扩展AVCapturePhotoOutput上遇到错误:AVCapturePhotoOutputType {}即扩展协议。这是错误

Type 'AVCapturePhotoOutput' does not conform to protocol 'AVCapturePhotoOutputType'

xCode也提供自动修复选项,当我申请生成两个存根时,我开始收到错误,如下图所示。

Errors after adding stubs

升级到xCode 9后,我不明白为什么会发生这种情况,我们将不胜感激。

ios swift xcode camera avcapturesession
1个回答
2
投票

我有完全相同的问题。只需用此协议替换您的协议即可

@objc protocol AVCapturePhotoOutputType {
@available(iOS 10.0, *)
var isLensStabilizationDuringBracketedCaptureSupported: Bool {get}
//### `availableRawPhotoPixelFormatTypes` is temporarily renamed to `__availableRawPhotoPixelFormatTypes`,
//### Maybe more Swiftish refinement is planned, but not yet completed.
@available(iOS 10.0, *)
@objc(availableRawPhotoPixelFormatTypes)
var __availableRawPhotoPixelFormatTypes: [NSNumber] {get}
@available(iOS 10.0, *)
var isHighResolutionCaptureEnabled: Bool {get @objc(setHighResolutionCaptureEnabled:) set}
@available(iOS 10.0, *)
//### `supportedFlashModes` is temporarily renamed to `__supportedFlashModes`,
//### Maybe more Swiftish refinement is planned, but not yet completed.
@objc(supportedFlashModes)
var __supportedFlashModes: [NSNumber] {get}
@available(iOS 10.0, *)
@objc(connectionWithMediaType:)
func connection(with mediaType: AVMediaType) -> AVCaptureConnection?
@available(iOS 10.0, *)
@objc(capturePhotoWithSettings:delegate:)
func capturePhoto(with settings: AVCapturePhotoSettings, delegate: AVCapturePhotoCaptureDelegate)
}

欢呼:-)

© www.soinside.com 2019 - 2024. All rights reserved.