ios - 无法将类型 'collectionScannerViewController' 的值转换为预期的参数类型 'AVCaptureMetadataOutputObjectsDelegate!'

标签 ios swift avfoundation

我有一些条形码扫描应用程序的代码,除了以下部分之外一切正常:

    if (captureSession.canAddOutput(metadataOutput)) {
    captureSession.addOutput(metadataOutput)
    metadataOutput.setMetadataObjectsDelegate(self,queue: DispatchQueue.main)
    metadataOutput.metadataObjectTypes = [AVMetadataObjectTypeEAN8Code, AVMetadataObjectTypeEAN13Code, AVMetadataObjectTypePDF417Code]

我收到错误:

Cannot convert value of type 'collectionScannerViewController' to expected argument type 'AVCaptureMetadataOutputObjectsDelegate!'

在线

metadataOutput.setMetadataObjectsDelegate(self,queue: DispatchQueue.main)

似乎不喜欢我使用 self 作为元数据对象委托(delegate),任何人都可以帮助我解释为什么吗?

最佳答案

没关系我找到了它,没有在顶部用我的 View Controller 声明 AVCaptureMetadataOutputObjectsDelegate。

关于ios - 无法将类型 'collectionScannerViewController' 的值转换为预期的参数类型 'AVCaptureMetadataOutputObjectsDelegate!',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40284675/

相关文章:

android - 将图像保存到自定义文件夹钛

ios - 堆栈 View ,将空间折叠到内容

iphone - 某些 View Controller 独有的自动旋转

ios - 如何在 Swift 中使用 MarqueeLabel?

swift - 创建 SKShapeNode 的子类

ios - 在 iOS 13 上,AVPlayer 为此 HLS 视频选择纯音频流。我可以控制这种行为,而是让它加载视频+音频吗?

ios - AVAssetExportSession - 导出的视频与相机胶卷不兼容

ios - 我的应用程序在App Store上不支持iPhone 4s和5吗?

xcode - swift : Searchbar localizedCaseInsensitiveContainsString is not working or error

ios - 将帧发送到服务器的最佳技术是什么,或者直播在 iOS 上如何工作?