【问题标题】:Swift Error : Use of module 'CMSampleBuffer' as a typeSwift 错误:使用模块“CMSampleBuffer”作为类型
【发布时间】:2014-06-22 21:41:36
【问题描述】:

我看到下面的问题是在 swift 中使用 'captureStillImageAsynchronouslyFromConnection' 函数: How to convert code AVFoundation objective c to Swift?

当我尝试如下使用 AVFoundation 函数时:

var stillImageOutput: AVCaptureStillImageOutput!

//...Initialize stillImageOutput

stillImageOutput.captureStillImageAsynchronouslyFromConnection(videoConnection, completionHandler: {(imageSampleBuffer, error) in
        if imageSampleBuffer {
            var imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(imageSampleBuffer as CMSampleBuffer) // I get error on this line saying: 'Use of module ' CMSampleBuffer' as a type'
            self.processImage(UIImage(data: imageData))
        }
        })

我在 XCode 上遇到错误,上面写着“使用模块 'CMSampleBuffer' 作为一种类型”。 我试图用略有不同的方式多次重写同一行,但我无法找出解决方案。

是我做错了什么还是可能是不稳定的 XCode Beta 无法正常工作?

提前谢谢你。

【问题讨论】:

  • 对我来说看起来像一个错误。如果你 import CoreMedia 可以工作
  • @ChristianDietrich 我认为这不是错误,由于没有import CoreMedia,它无法识别类型。此外,不需要类型转换。

标签: xcode avfoundation swift


【解决方案1】:

@Jack 和@Christian 的解决方案对我有用。 导入 CoreMedia 时我不够小心。 我以前从未使用过这个框架,也不知道问题是不是因为没有导入正确的框架。 感谢您的帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-22
    • 2020-10-08
    • 1970-01-01
    • 2022-01-23
    • 2019-02-21
    相关资源
    最近更新 更多