Giter VIP home page Giter VIP logo

barcodescanner's Introduction

BarcodeScanner

BarcodeScanner is an open source project which let you easy to get barcode contents.

Supported Types

  • UPC CODE
  • EAN CODE (EAN-13, EAN-8)
  • CODE 39
  • CODE 128
  • ITF (Interleaved 2 OF 5)
  • CODE 93
  • QR CODE
  • DATAMATRIX CODE
  • PDF417
  • AZTEC

Installation

  • Link AVFoundation.framework in Build Phases
  • You can download the Barcode.swift file into your project directly.
  • If you want to import to Objective-C project. You also need to configure Xcode. Please reference this link.

Setting Info.plist

To effect iOS 10 privacy policy, you must provide usage description for camera.

<key>NSCameraUsageDescription</key>
<string>Used to scan QR code</string>

How to use

To use this library in your project is very easy. BarcodeScanner is a ViewController so that you just present a ViewController to launch it and use dismiss to close it.

  • Inital this object and assign delegate
let barcodeViewController = BarcodeScannerViewController()
barcodeViewController.cancelButton_Text = "取消" // customize text of cancel button, default text is "Cancel"
barcodeViewController.delegate = self
  • Launch camera to scan barcode in your ViewController
self.present(barcodeViewController, animated: true, completion: nil)
  • You should adopt BarcodeSacnnerDelegate protocol and implement that method in your ViewController. The result from BarcodeScanner will use callback method let you get.
class ViewController: UIViewController, BarcodeScannerDelegate {
...
    // MARK: - BarcodeScannerDelegate
    func barcodeScannerController(_ scanner: BarcodeScannerViewController, didFinishPickingBarcodeContent content: String?) {
        var result = content ?? "" // BarcodeScanner returns String let you to do what you want
        scanner.dismiss(animated: true) // remember to dismiss the Barcode ViewController
    }

}

Author

Nick Yang (Profile)

barcodescanner's People

Contributors

nick10811 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.