如何为Swift实现AVCam [英] How to implement AVCam for Swift

查看:301
本文介绍了如何为Swift实现AVCam的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我找到两个关于AVCam的链接


  1. Apple: https://developer.apple.com/library/ios/samplecode/AVCam/History/History.html

  2. alex-chan / AVCamSwift: https://github.com/alex-chan / AVCamSwift

第一个链接的演示文件可以正常工作,但它在Object-C关于将Object-C转换为Swift的文档?



第二个链接我已经下载了文件,但它不会在我的4s运行 - 有人可以告诉我为什么? >

我想有一个swift版本,所以我可以很容易地采用它到我的swift build +感谢再次SO!

解决方案

如果你有一个工作objc版本为什么不只是导入它与桥接头?没有一个关于将obj-c转换为swift的文档,如果你真的想转换它,你需要逐行执行。



你想做什么?获得实时相机馈送显示?这些文档已被移植到swift并适合这个目的,但您需要先获取输入端口。



https://developer.apple.com/library/mac /documentation/AVFoundation/Reference/AVCaptureVideoPreviewLayer_Class/index.html#//apple_ref/occ/clm/AVCaptureVideoPreviewLayer/layerWithSession



更新:如何导入obj -c头文件,一种更新的方式来创建它们,但是没有谈到的只是创建任何正常的.m文件或​​目标c文件,然后选择是创建一个briding标头,它配置一切为你。
据说,在尝试实现此类功能之前,如果您遇到关于链接的问题,可能需要更多地了解一些基本知识,或者遵循一些指南。



以下是随机应用程式制作指南 http://www.ioscreator.com/tutorials/calculator-tutorial-in-ios8-with-swift ,应该教你多少。我会推荐跟随和阅读这样的东西,直到你有一个更多的基础,并可以提出更多的确切问题。没有人会在这里为你重写苹果程序,你的问题是非常广泛的。


Hello I have found two links about AVCam

  1. Apple: https://developer.apple.com/library/ios/samplecode/AVCam/History/History.html
  2. alex-chan/AVCamSwift: https://github.com/alex-chan/AVCamSwift

The first link has demo files that work perfectly, but its in Object-C - can someone show me documentation on converting Object-C to Swift?

The second link I have downloaded the files but it will not run in my 4s - can someone tell me why?

I would like to have a swift version so I can easily adopt it into my swift build + thanks again SO!

解决方案

if you have a working objc version why not just import it with a bridging header? there is no one document about converting obj-c to swift, if you really want to convert it you are going to need to do it line by line.

also what exactly are you trying to do? get a live camera feed displayed? these docs have been ported to swift and would suit that purpose but you would need to get the input port first.

https://developer.apple.com/library/mac/documentation/AVFoundation/Reference/AVCaptureVideoPreviewLayer_Class/index.html#//apple_ref/occ/clm/AVCaptureVideoPreviewLayer/layerWithSession:

Update: how to import obj-c headers, a newer way to create them that isnt quite as talked about yet is to just create any normal .m file or objective c file then select yes to creating a briding header, it configures everything for you. That being said it may be worth while to play around with the basics a bit more and maybe follow a few guides before attempting to implement this type of feature if you are having issues with following the links.

Here is a random application creation guide http://www.ioscreator.com/tutorials/calculator-tutorial-in-ios8-with-swift that should teach you alot. i would recommend following and reading through stuff like this until you have a bit more of a footing and can come up with more of an exact question. no one here is going to rewrite the apple program for you and your questions are extremely broad.

这篇关于如何为Swift实现AVCam的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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