【发布时间】: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