ZXingObjc - Converting object c to swift

后端 未结 1 995
一生所求
一生所求 2021-01-06 21:14

I\'m a newbie with Ios. i\'m learning swift and overlooked object c.

Currently, i\'m writing an demo with swift and xcode 6.1 which can scan qrcode and barcode from

相关标签:
1条回答
  • 2021-01-06 21:48

    You're almost there — this should get you the rest of the way. Note the comments:

    // initializers are imported without "initWith"
    let source: ZXLuminanceSource = ZXCGImageLuminanceSource(CGImage: tempImage)
    let binazer = ZXHybridBinarizer(source: source)
    let bitmap = ZXBinaryBitmap(binarizer: binazer)
    
    var error: NSError?
    
    var hints = ZXDecodeHints()
    var reader = ZXMultiFormatReader()
    // 1) you missed the name of the method, "decode", and
    // 2) use optional binding to make sure you get a value
    if let result = reader.decode(bitmap, hints:hints, error: error) {
        lblResult.text = result.text;
    }
    
    0 讨论(0)
提交回复
热议问题