使用AVFoundation读取二进制QR码 [英] Read binary QR Code with AVFoundation

查看:168
本文介绍了使用AVFoundation读取二进制QR码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用AVFoundation读取二进制编码的QR码?

Is it possible to read a binary encoded QR code with AVFoundation?

我可以获得 AVMetadataMachineReadableCodeObject 对象 .type AVMetadataObjectTypeQRCode ,但这只有 stringValue 属性,这将无法工作,因为QR码中包含的数据无法转换为字符串友好表示。

I can get a AVMetadataMachineReadableCodeObject object of .type AVMetadataObjectTypeQRCode, however this only has a stringValue property, which won't work, because the data contained in the QR code can't be converted to a string friendly representation.

我应该使用ZXing吗?

Should I use ZXing instead?

谢谢

推荐答案

原始数据确实存在于您的<$ c $中c> AVMetadataMachineReadableCodeObject ,但它不能通过公共getter获得。

The raw data does exist in your AVMetadataMachineReadableCodeObject, but it's not available through a public getter.

但是,您可以使用KVO来提取它,但Apple可能会拒绝您的应用程序。此外,未来的iOS版本可能会更改其私有API,您的代码可能会变得无效(因为硬编码的私钥)。

However, you can use KVO to extract it, but Apple might reject your app. Also, future iOS versions might change their private APIs and your code could become invalid (because of the hardcoded private keys).

Swift:

readableCodeObject.valueForKeyPath("_internal.basicDescriptor")!["BarcodeRawData"]

Objective-C

Objective-C

[readableCodeObject valueForKeyPath:@"_internal.basicDescriptor"][@"BarcodeRawData"];

我为iOS 8和9测试了这个。

I tested this for iOS 8 and 9.

这篇关于使用AVFoundation读取二进制QR码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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