我想問一下是不是可以讀取VCF卡像給定名稱,familyName CNContact數據...從QR碼中讀取VCFCard?
這是我的QR碼掃描輸出功能
func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputMetadataObjects metadataObjects: [Any]!, from connection: AVCaptureConnection!) {
if metadataObjects == nil || metadataObjects.count == 0 {
qrCodeFrameView?.frame = CGRect.zero
messageLabel.text = "No QR/barcode is detected"
return
}
let metadataObj = metadataObjects[0] as! AVMetadataMachineReadableCodeObject
if supportedCodeTypes.contains(metadataObj.type) {
let barCodeObject = videoPreviewLayer?.transformedMetadataObject(for: metadataObj)
qrCodeFrameView?.frame = barCodeObject!.bounds
if metadataObj.stringValue != nil {
messageLabel.text = metadataObj.stringValue
}
}
}
打印輸出
"
<AVMetadataMachineReadableCodeObject: 0x17022d1e0, type="org.iso.QRCode", bounds={ 0.3,0.4 0.1x0.3 }>corners { 0.3,0.7 0.5,0.7 0.5,0.4 0.3,0.4 }, time 93849323998125, stringValue "BEGIN:VCARD
VERSION:3.0
PRODID:-//Apple Inc.//iPhone OS 10.2//EN
N:Hank;Patrick;;;
FN: Patrick Hank
EMAIL;type=INTERNET;type=HOME;type=pref:[email protected]
TEL;type=IPHONE;type=CELL;type=VOICE;type=pref:0911311911
END:VCARD
"
你的代碼沒有'print',所以我不確定你的「打印輸出」是什麼。但是你可以嘗試'CNContactVCardSerialization'。 – OOPer
我在MessageLabel.text下添加了...等。 ... print(metadataObj)..嘗試但不知道如何 – patrikbelis