我在我的应用程序中使用qr代码,它也以AVMetadataMachineReadableCodeObject的形式给出了响应。这是我的代表处理响应。
func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [Any]!, from connection: AVCaptureConnection!) {
if strFound == ""
{
// Check if the metadataObjects array is not nil and it contains at least one object.
if metadataObjects == nil || metadataObjects.count == 0 {
qrCodeFrameVieww?.frame = CGRect.zero
messageLabel.text = "No QR/barcode is detected"
return
}
// Get the metadata object.
let metadataObj = metadataObjects[0] as! AVMetadataMachineReadableCodeObject
if supportedCodeTypes.contains(metadataObj.type) {
// If the found metadata is equal to the QR code metadata then update the status label's text and set the bounds
let barCodeObject = videoPreviewLayer?.transformedMetadataObject(for: metadataObj)
//qrCodeFrameVieww?.frame = barCodeObject!.bounds
if defaults.value(forKey: "beep") as! Bool != false
{
playSound()
}
if defaults.value(forKey: "vibrate") as! Bool != false
{
AudioServicesPlayAlertSound(SystemSoundID(kSystemSoundID_Vibrate))
AudioServicesPlaySystemSoundWithCompletion(SystemSoundID(kSystemSoundID_Vibrate), nil)
}
print("type is",metadataObj.type)
print("metaDataObj",metadataObj)
foundCode(code: metadataObj.stringValue as NSString)
if metadataObj.stringValue != nil {
let stUrl = metadataObj.stringValue as String
print("The Url Is \(stUrl)")
if defaults.value(forKey: "copyToClipboard") as! Bool == true
{
UIPasteboard.general.string = stUrl
}
}
我的问题是,qrcode代码可以扫描vcards,电话号码,电子邮件,地理位置和日历事件等。我怎么知道我在响应字符串中有什么样的数据,就好像它是一个相关的vcard还是网址或日历活动?
答案 0 :(得分:0)
Phrase phrase = new Phrase();
var text1 = new Chunk("hello");
var text2=new Chunk("world");
phrase.add();