Swift错误:使用模块'CMSampleBuffer'作为类型 [英] Swift Error : Use of module 'CMSampleBuffer' as a type

查看:107
本文介绍了Swift错误:使用模块'CMSampleBuffer'作为类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到了以下问题,迅速使用'captureStillImageAsynchronouslyFromConnection'函数: 如何将代码AVFoundation目标c转换为Swift?

I saw below question to use 'captureStillImageAsynchronouslyFromConnection' function in swift: How to convert code AVFoundation objective c to Swift?

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

When I try to use a AVFoundation function as following:

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'作为类型". 我试图用略有不同的方式多次重写同一行,但是我找不到解决方法.

I got the error on XCode, which says 'Use of module ' CMSampleBuffer' as a type'. I tried to rewrite that same line multiple times with slightly different ways, but I could not figure out the solution.

我做错什么了吗,或者不稳定的XCode Beta无法正常工作?

Am I doing something wrong or is it possibly the shaky XCode Beta not working properly?

谢谢.

推荐答案

@Jack和@Christian的解决方案对我有用. 我没有足够谨慎地导入CoreMedia . 我以前从未使用过此框架,也不知道问题是否是由于未导入正确的框架引起的. 谢谢您的帮助!

@Jack and @Christian's solutions worked for me. I was not careful enough to import CoreMedia. I never used this framework before, and did not know if the problem was due to not having imported a correct framework. Thank you for your help!

这篇关于Swift错误:使用模块'CMSampleBuffer'作为类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆