Xcode Swift错误:使用模块';CMSampleBuffer';作为一种类型
我在swift中看到了使用“captureStillImageAsynchronouslyFromConnection”函数的以下问题: 当我尝试使用AVFoundation函数时,如下所示:Xcode Swift错误:使用模块';CMSampleBuffer';作为一种类型,xcode,avfoundation,swift,Xcode,Avfoundation,Swift,我在swift中看到了使用“captureStillImageAsynchronouslyFromConnection”函数的以下问题: 当我尝试使用AVFoundation函数时,如下所示: var stillImageOutput: AVCaptureStillImageOutput! //...Initialize stillImageOutput stillImageOutput.captureStillImageAsynchronouslyFromConnection(video
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测试版工作不正常
提前谢谢你。@Jack和@Christian的解决方案对我很有用。 我没有足够小心地导入CoreMedia。 我以前从未使用过这个框架,也不知道问题是否是由于没有导入正确的框架造成的。
谢谢你的帮助 在我看来像个虫子。如果您
导入CoreMedia
@ChristiandeTrich,则该功能正常。我认为这不是一个bug,它无法识别该类型,因为没有导入CoreMedia
。而且,不需要类型转换。