我正在处理另一位开发人员的代码,它是一个相机应用程序。我对其进行了研究,在升级到 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 {} 上遇到错误,即扩展协议(protocol)。这是错误
Type 'AVCapturePhotoOutput' does not conform to protocol 'AVCapturePhotoOutputType'
xCode 还提供自动修复选项,当我应用生成两个 stub 时,我开始收到错误,如下图所示。
我不明白为什么升级到 xCode 9 后会发生这种情况,任何帮助将不胜感激。
最佳答案
我遇到了完全相同的问题。只需用此协议(protocol)替换您的协议(protocol)即可
@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)
}
干杯:-)
关于ios - 将 Xcode 8 升级到 XCode 9 后出现 AvCapture 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48023849/