Skip to content

Swift/iOS Code for presenting a barcode reader using the camera

License

Notifications You must be signed in to change notification settings

fortesdev/BarcodeReaderUI

Repository files navigation

BarcodeReaderUI

Swift/iOS Code for presenting a barcode reader using the camera

BarcodeReader UI as popover

Usage:

#1 Set in your info.plist a value for "Privacy - Camera Usage Description" (ie "This app uses the camera to scan barcodes"), otherwise it will not run.

#2 Define your ViewController as BarcodeReaderVCDelegate. You'll receive the barcode value in the method below:

extension ViewController: BarcodeReaderVCDelegate {
    func barcodeFound(_ barcode: String) {
        print("Barcode Found!! \(barcode)")
    }    
}

#3 Present the Barcode Reader UI from your ViewController setting its delegate from the provided storyboard and class, ie:

let storyboard = UIStoryboard(name: "BarcodeReader", bundle: nil)
if let vc = storyboard.instantiateViewController(withIdentifier: "BarcodeReaderVC") as? BarcodeReaderVC {
        vc.modalPresentationStyle = .popover
        vc.delegate = self
        self.present(vc, animated: true)
}

About

Swift/iOS Code for presenting a barcode reader using the camera

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages