斯威夫特:不管我做什么CIDetector总是零 [英] Swift : No Matter what I do CIDetector is always nil

查看:132
本文介绍了斯威夫特:不管我做什么CIDetector总是零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白为什么这段代码不起作用,检测器总是带有CIDetectorTypeQRCode常量为零,所有内容都适用于CIDetectorTypeFace。
我怀疑Apple的API有一个错误。这是官方文档: Apple文档

i don't understand why this code doesn't work, the detector is always nil with the CIDetectorTypeQRCode constant, everything work with CIDetectorTypeFace. I Supect a bug from API of Apple. This a the official doc : Apple documentation

@IBAction func analyseTag(sender: AnyObject) {

        var detector:CIDetector = CIDetector(ofType: CIDetectorTypeQRCode, context:nil, options:[CIDetectorAccuracy: CIDetectorAccuracyHigh])
        var decode = ""
        var ciImage:CIImage = CIImage(image: ImgChoosed.image)
        var message:String = "";

        let features = detector.featuresInImage(ciImage)
        for feature in features as [CIQRCodeFeature] {
            message += feature.messageString
        }

        if(message == "") {
            println("nothing")

        } else {
            println("\(message)")
        }



    }

你有没有一个办法?
先谢谢你了

Have you a solution? Thank in advance guy's

推荐答案

这也发生在我们身上。 iPhone 4s不会返回QRCode类型的CIDetector。其他类型(矩形,面部)工作虽然...

This happened to us as well. iPhone 4s doesn't return a CIDetector of type QRCode. The other types (rectangle, face) work though…

相同的代码在iPhone 6上按预期工作。尚未测试5或5s。

The same code works as expected on the iPhone 6. Haven't tested on a 5 or 5s yet.

但两周前,我相信它还在4s上工作。当时它仍然在iOS 8上,我想。

But two weeks ago it was still working on the 4s, I believe. It was still on iOS 8 back then, I guess.

这篇关于斯威夫特:不管我做什么CIDetector总是零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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